Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphql-nextjs: Can't write schema.graphql to file system (Error: EACCES: permission denied, open '/schema.graphql') #1543

Closed
ajmajma opened this issue Feb 27, 2020 · 8 comments · May be fixed by Edjevw12/prisma-examples#1

Comments

@ajmajma
Copy link

ajmajma commented Feb 27, 2020

Hey all,

Trying to fool around with the graphql-nextjs example to get myself acquainted - but I am seeing problems in the console. In the console I am seeing

[Error: EACCES: permission denied, open '/schema.graphql'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/schema.graphql'
}

This is a fresh install as of today. Using node 13.7.0 if this helps.

@nikolasburk
Copy link
Member

Hey @ajmajma, thanks a lot for opening this issue. I just checked and the error doesn't seem problematic. For some reason Nexus isn't able to write the schema.graphql file to the file system.

I changed the title of this issue to reflect that.

@nikolasburk nikolasburk changed the title EACCES error with graphql-nextjs graphql-nextjs: Can't write schema.graphql to file system (Error: EACCES: permission denied, open '/schema.graphql') Feb 28, 2020
@ajmajma
Copy link
Author

ajmajma commented Feb 28, 2020

Hey @nikolasburk thanks for updating this. I don't know if this is related but the generate:nexus seems to also be breaking. When I try to run it, the console is giving me :

(node:32915) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
/Users/amoser/Desktop/prisma-examples-prisma2 3/typescript/graphql-nextjs/pages/api/index.ts:1
import { idArg, makeSchema, objectType, stringArg, asNexusMethod } from 'nexus';
^^^^^^

SyntaxError: Cannot use import statement outside a module

@JorgeCeja
Copy link

The problem is with "module" from tsconfig.json. If you switch from "module":"esnext" to "module": "commonjs" the issue is fixed. However, nextjs requires esnext for dynamic import() support.

This is just a workaround, it'll be great to find a solution that works for both nextjs and nexus.

P.S. I'm also running into 'Error: EACCES: permission denied, open '/schema.graphql'' issue with node 10

@yassinebridi
Copy link

This is probably obvious,
but as a workaround, i executed yarn dev with sudo privileges.
@JorgeCeja when i change the module to commonjs, the compiler tries to edit the module back to esnext.

@Edjevw12
Copy link

Edjevw12 commented Apr 6, 2020

I changed __dirname to process.cwd() and it worked for me.

  types: [Query, Mutation, User],
  outputs: {
    typegen: process.cwd() + '/pages/api/nexus-typegen.ts',
    schema: process.cwd() + '/pages/api/schema.graphql',
  },
});

@nikolasburk
Copy link
Member

@Edjevw12 do you mind submitting a PR with this solution 🙂

@akshaylive
Copy link
Contributor

FWIW, I've created a PR that fixes this and a few related issues.

@nikolasburk
Copy link
Member

Thanks a lot @akshaylive, the PR is merged 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants