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
devDependencies
worked for me:I had the same issue with our CI workflow and the downgrading didn’t help. But installing graphql helps
npm install -g graphql
What 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
BUG
WOW. 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-server
requiring@apollo/federation@0.27.0
but@apollo/federation@0.27.0
no longer working withgraphql@14
(see https://github.com/apollographql/federation/issues/904).@apollo/federation
corrected this issue in 0.27.1 by requiringgraphql@15.4
or higher as peer dependency, dropping the support forgraphql@14
.There are 2 options to fix this issue here:
@apollo/federation
insideapollo-language-server
to a version that still works withgraphql@14
graphql@15.4
(currently they are not, see e.g. https://github.com/apollographql/apollo-tooling/issues/2232) and drop support for anygraphql
version 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.json
and 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
apollo
to2.33.4
andapollo-language-server
to1.26.3
worked for meThanks for the above…the following worked for me…
RUN npm install -g apollo@2.34.0 graphql@16.6.0
running 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:download
using npx today:npx apollo@2 schema:download
and observe the path in the error/Users/foobar/.npm/_npx/XXXXXXXXXXXXXXXX
cd /Users/foobar/.npm/_npx/XXXXXXXXXXXXXXXX
npm install apollo@2.33.4 apollo-codegen-core@0.40.3 apollo-language-server@1.26.3
npx apollo@2 schema:download
should now work 🎉Thank you @sergpetrov your solution to install graphql globally worked perfectly for me too
npm install -g graphql
Rover 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.1
butv12.18.4
.If you’re using Node 16, see @LukeAvsec-DarwinHomes’s solution above.
We wanted to be able to run
apollo client:codegen
as 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-apollo
installation)graphql@15.5.0
(for basevue-apollo
installation)vue-apollo@3.0.7
apollo-utilities@1.3.4
(added later to configure the in-memory cache)apollo@2.33.6
(for thecodegen
CLI)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
apollo
dependency and change our npm scripts to usenpx apollo client:codegen
instead. Of course,npx
has 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
graphql
did 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
gql
tag stuff intosomething.gql
files, pointed theapollo.config.js
file 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