No valid exports main found for '/Users/victor/Desktop/test/node_modules/extract-files'
I get this error when I run npx graphql-codegen init
I think this was fixed in: https://github.com/dotansimha/graphql-code-generator/pull/3869
@VictorArowo can you please share a reproduction? I'm not sure why the error is coming from extract-files...
It is npx @graphql-codegen/cli init. Not npx grapgql-codegen init. Could you try the correct one?
Error still persists with 1.13.2 and 1.13.3, but it works fine on 1.13.1.
@ardatan I don't think the command is the problem, since it works fine on 1.13.1
Experiencing the same issues...
My config is:
overwrite: true
schema: "https://..."
documents:
- "./queries/*.ts"
generates:
src/@types/graphql.ts:
plugins:
- add: "/* eslint-disable @typescript-eslint/no-explicit-any */"
- add: "// @ts-nocheck"
- "typescript"
- "typescript-operations"
- "fragment-matcher"
- "typescript-vue-apollo"
config:
withCompositionFunctions: true
Versions:
"@graphql-codegen/add": "^1.13.3",
"@graphql-codegen/cli": "^1.13.3",
"@graphql-codegen/fragment-matcher": "^1.13.3",
"@graphql-codegen/typescript": "^1.13.3",
"@graphql-codegen/typescript-graphql-files-modules": "^1.13.3",
"@graphql-codegen/typescript-operations": "^1.13.3",
"@graphql-codegen/typescript-vue-apollo": "^1.13.3",
Seems the module extract-files used by apollo-upload-client was causing my issues. It probably has to do with change sintroduced in [email protected] (https://github.com/jaydenseric/extract-files/releases/tag/v8.0.0).
Updated to NodeJS 13.13.0 and now everything works as expected.
I suddenly got this issue today. It worked just yesterday.
@tanduong can you please share a reproduction?
Thank @dotansimha for the response. I tried to reproduce but this is the best I got. Here is some of the commands:
> node -v
v10.15.3
> nvm use 13
Now using node v13.2.0 (npm v6.13.1)
> npx graphql-codegen
No valid exports main found for '/Users/tanduong/Code/nab-clone/node_modules/extract-files'
> rm -rf node_modules/
> npm i
...
> npx graphql-codegen
✔ Parse configuration
✔ Generate outputs
It seems delete node_modules and reinstall works. Here is my repo: https://github.com/tanduong/nab
I guess it's related to NodeJS version, as @farcasmihai91 found. So if you are changing your NodeJS version, you must reinstall deps in order to get this working.
Still having this issue with version 1.15.4 , should I downgrade ?
"@graphql-codegen/cli": "^1.15.4",
"@graphql-codegen/introspection": "^1.15.4",
"@graphql-codegen/typescript": "^1.15.4",
"@graphql-codegen/typescript-apollo-angular": "^1.15.4",
"@graphql-codegen/typescript-operations": "^1.15.4",
"graphql": "^14.6.0",
"graphql-tag": "^2.10.3",
"graphql-toolkit": "^0.7.5",
Please avoid using this character ^ in package.json. That might cause having incompatible versions installed in the same project. So we recommend to use exact version.
Also graphql-toolkit has been deprecated, you can migrate to new graphql-tools instead :)
https://www.graphql-tools.com/docs/migration-from-toolkit
Please avoid using this character ^ in package.json. That might cause having incompatible versions installed in the same project. So we recommend to use exact version.
Alsographql-toolkithas been deprecated, you can migrate to new graphql-tools instead :)
https://www.graphql-tools.com/docs/migration-from-toolkit
i'll give it a shot
@ardatan I have tried deleting my node_modules folder and reinstalled with the following versions. Still having issues.
node v13.3.0
npm 6.13.1
"@graphql-codegen/cli": "1.15.4",
"@graphql-codegen/introspection": "1.15.4",
"@graphql-codegen/typescript": "1.15.4",
"@graphql-codegen/typescript-apollo-angular": "1.15.4",
"@graphql-codegen/typescript-operations": "1.15.4",
"graphql": "^14.6.0",
"graphql-client": "^2.0.1",
"graphql-tag": "^2.10.3",
"graphql-tools": "^6.0.11",
"apollo-angular": "^1.9.1",
"apollo-angular-link-http": "^1.10.0",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link": "^1.2.14",
"apollo-link-ws": "^1.0.20",
"apollo-server-express": "^2.11.0",
"apollo-utilities": "^1.3.4",
I see so please submit an issue by following the instruction on the template;
https://github.com/dotansimha/graphql-code-generator/issues/new?template=bug_report.md
Most helpful comment
Seems the module
extract-filesused byapollo-upload-clientwas causing my issues. It probably has to do with change sintroduced in[email protected](https://github.com/jaydenseric/extract-files/releases/tag/v8.0.0).Updated to NodeJS 13.13.0 and now everything works as expected.