apollo-tooling: cannot find module error for apollo-cli 2.33.{6,7,8,9}
When I was trying to upgrade the formula to use the latest 2.33.6 release, it looks like the apollo command does not work anymore.
$ /usr/local/Cellar/apollo-cli/2.33.6/bin/apollo client:check
Error: Cannot find module
'graphql/validation/rules/KnownArgumentNamesRule'
Require stack:
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/@apollo/federation/dist/composition/validate/preNormali
zation/tagDirective.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/@apollo/federation/dist/composition/validate/preNormali
zation/index.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/@apollo/federation/dist/composition/validate/index.js
-
/usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo/n
ode_modules/@apollo/federation/dist/composition/composeAndValidate.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/@apollo/federation/dist/composition/index.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/@apollo/federation/dist/index.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/apollo-language-server/lib/providers/schema/file.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/apollo-language-server/lib/providers/schema/index.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/apollo-language-server/lib/project/base.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/apollo-language-server/lib/index.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/lib/Command.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/lib/commands/client/check.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/@oclif/config/lib/plugin.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/@oclif/config/lib/config.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/@oclif/config/lib/index.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/@oclif/command/lib/command.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/node_modules/@oclif/command/lib/index.js
- /usr/local/Cellar/apollo-cli/2.33.6/libexec/lib/node_modules/apollo
/bin/run
Code: MODULE_NOT_FOUND
relates to https://github.com/Homebrew/homebrew-core/pull/83152
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 64
- Comments: 65 (1 by maintainers)
Commits related to this issue
- temp fix for https://github.com/apollographql/apollo-tooling/issues/2415 — committed to kyh/2up by kyh 3 years ago
- Pin apollo to 2.33.4 and apollo-language-server to 1.26.3 Unpin when the following PR is fixed. https://github.com/apollographql/apollo-tooling/issues/2415 — committed to arkipel/arkipel-client by mfcochauxlaberge 3 years ago
- Update "Exporting the Hasura GraphQL schema" documentation The `apollo service:*` commands [are deprecated](https://www.apollographql.com/docs/devtools/cli/). It is now advised by Apollo to use their... — committed to fungiboletus/graphql-engine by fungiboletus 2 years ago
- Update export-graphql-schema.rst The `apollo service:*` commands [are deprecated](https://www.apollographql.com/docs/devtools/cli/). It is now advised by Apollo to use their [Rover](https://www.apoll... — committed to fungiboletus/graphql-engine by fungiboletus 2 years ago
- chore(client): install/pin apollo CLI & graphql package versions - related: https://github.com/apollographql/apollo-tooling/issues/2415#issuecomment-998920583 — committed to neopostmodern/structure by neopostmodern 2 years ago
- temp fix for https://github.com/apollographql/apollo-tooling/issues/2415 — committed to kyh/2up by kyh 3 years ago
- temp fix for https://github.com/apollographql/apollo-tooling/issues/2415 — committed to kyh/2up by kyh 3 years ago
- temp fix for https://github.com/apollographql/apollo-tooling/issues/2415 — committed to kyh/2up by kyh 3 years ago
This issue is still a problem. It gave me 12-hours of pain. Nothing in this thread solved it for me although the information and context were very useful.
These pinned
devDependenciesworked for me:I had the same issue with our CI workflow and the downgrading didn’t help. But installing graphql helps
npm install -g graphqlWhat a Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega Mega
BUGWOW. Please someone from Apollo fix this! (Almost 1 year later).
Is there any solution except downgrading nodejs and/or npm’s and/or apollo’s versions ?
Which will happen first: this gets fixed, or George R.R. Martin releases his next GoT book?
I have the same error as the screenshot on environment node v16.6.2. When I downgrade node to v14.17.5 (npm v6.14.14) and re-install it’s worked for me.
Guys the solution for this is that you need to check the version of your graphql that is compatible with your apollo. For example: i had the graphql version 14.5.8 and my apollo version was 2.33.9. These are not compatible. I had to check in my node_modules the folder for apollo, check the package.json ((you should see something like this “graphql”: “14.0.2 - 14.2.0 || ^14.3.1 || ^15.0.0”)) and wich versions are compatible with the version that i current had. In this case i just update it to graphql 15.8.0. And it works
This issue is caused by
apollo-language-serverrequiring@apollo/federation@0.27.0but@apollo/federation@0.27.0no longer working withgraphql@14(see https://github.com/apollographql/federation/issues/904).@apollo/federationcorrected this issue in 0.27.1 by requiringgraphql@15.4or higher as peer dependency, dropping the support forgraphql@14.There are 2 options to fix this issue here:
@apollo/federationinsideapollo-language-serverto a version that still works withgraphql@14graphql@15.4(currently they are not, see e.g. https://github.com/apollographql/apollo-tooling/issues/2232) and drop support for anygraphqlversion lower than 15.4.@LukeAvsec-DarwinHomes Thank you so much. Was trying to fix versions for a long time, couldn’t find the right one till now!
How is this not getting more traction?
package.json:
@LukeAvsec-DarwinHomes man you are a life saver
I’ve added the following postinstall script to the scripts section of my
package.jsonand it work for me and my co-worker:Okay made it work guys, using the latest version of the package but using
node 14.16.0:The moment I changed node version with nvm everything worked 🙏
Pinning
apolloto2.33.4andapollo-language-serverto1.26.3worked for meThanks for the above…the following worked for me…
RUN npm install -g apollo@2.34.0 graphql@16.6.0running from Docker
@stephichau I was in my project using node v16.13.0, NPM v8.1.0, graphql v16.0.1 and apollo v2.33.8. It was giving me this same error, so I put graphql in peerDependencies, removed node_modules and installed again. But in another project this approch didn’t work. The node, npm, graphql and apollo versions are old and cannot update them. So I installed graphql and apollo globally, because I just needed the schema file.
Hi, we were stuck on this and was blocking us.
This is what worked for us:
Switching to yarn worked for us somehow, hope this can help.
Met same issue, but downgrading to 2.33.4 didn’t help
A super hacky way to run
apollo@2 schema:downloadusing npx today:npx apollo@2 schema:downloadand observe the path in the error/Users/foobar/.npm/_npx/XXXXXXXXXXXXXXXXcd /Users/foobar/.npm/_npx/XXXXXXXXXXXXXXXXnpm install apollo@2.33.4 apollo-codegen-core@0.40.3 apollo-language-server@1.26.3npx apollo@2 schema:downloadshould now work 🎉Thank you @sergpetrov your solution to install graphql globally worked perfectly for me too
npm install -g graphqlRover CLI doesn’t support codegen yet
installing apollo globally and then running the codegen worked for me
running the apollo service through a package.json script stil doesn’t work
it worked!! it worked!! thanks @LukeAvsec-DarwinHomes
What worked for me on a mac:
@traviscollins for us @LukeAvsec-DarwinHomes solution is not working with node
v16.13.1butv12.18.4.If you’re using Node 16, see @LukeAvsec-DarwinHomes’s solution above.
We wanted to be able to run
apollo client:codegenas an npm script to update our TypeScript types. This turned out to be kind of awkward because we’d followed vue-apollo’s instructions and had already indirectly installed Apollo’s sub-dependencies viaapollo-boost. We did manage to get the CLI to work for a few months with the following combination of explicit dependencies (dev and otherwise):apollo-boost@0.4.9(for basevue-apolloinstallation)graphql@15.5.0(for basevue-apolloinstallation)vue-apollo@3.0.7apollo-utilities@1.3.4(added later to configure the in-memory cache)apollo@2.33.6(for thecodegenCLI)Then, about a week ago, we had to reinitialize our
package-lock.json(for reasons I’ll not get into here) and came across the same error as in this ticket (Cannot find module 'graphql/validation/rules/KnownArgumentNamesRule'). @WIStudent does an excellent root cause analysis in their comment above. No combination of downgrades resolved the error.Our workaround was to uninstall our
apollodependency and change our npm scripts to usenpx apollo client:codegeninstead. Of course,npxhas to install all the dependencies it needs at runtime, but they do at least resolve to a combination of dependencies that work.On Node
v16.8.0, when I try to pin by adding versions topackage.json(I’m in a monorepo, this has been added to the rootpackage.json), I get the following error:This may be specific to my case, but it results in this fix not working for me (everything worked as of a week ago, and nothing in my code has changed). Presumably this is an internal dependency issue within Apollo?
Below solution worked for me https://www.appsloveworld.com/nodejs/100/127/error-cannot-find-module-graphql-validation-rules-possibletypeextensions we just need to run sudo npm install -g graphql
From what I understand it isn’t going to. Apollo recommends graphql-code-generator but I believe it doesn’t cover quite every use case.
Consider using the Rover CLI instead of a deprecated tool.
anybody tried this on an arm64/M1? solutions from above didn’t work for me.
fwiw @LukeAvsec-DarwinHomes 's solution is working for me w/ node
v16.14.1(using graphql^14.7.0)I’m running into this issue as well, posting for notifications and updates 👍 I was following this tutorial on a fresh project. https://www.apollographql.com/blog/tooling/apollo-codegen/typescript-graphql-code-generator-generate-graphql-types/
Locking the versions and installing
graphqldid not help.Got tired of waiting and the proposed fixes didn’t work for me, so I switched to graphql-code-generator.
Differences:
Edit: I think I’ve got a good configuration now: I’ve moved the
gqltag stuff intosomething.gqlfiles, pointed theapollo.config.jsfile to only include those files (so I don’t lose VSCode Apollo app autocompletion etc), and running graphql-code-generator on those to generate the TypeScript hooks