apollo-tooling
apollo-tooling copied to clipboard
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
Met same issue, but downgrading to 2.33.4 didn't help
I tried going all the way back to 2.20.0 just for kicks and it's broken with the same error:
"graphql-download": "npx [email protected] schema:download --endpoint=https://..../graphql schema.json",
I thought using npx
with a pinned version would mean "this should never break", but I guess not?
I am having the same issue--downgrading does not help.
I tried going all the way back to 2.20.0 just for kicks and it's broken with the same error:
"graphql-download": "npx [email protected] schema:download --endpoint=https://..../graphql schema.json",
I thought using
npx
with a pinned version would mean "this should never break", but I guess not?
I believe there's no package-lock.json
so it'll just get the latest ... and break.
I'm broken too as of 2+ hours ago on v2.22.0
Met same issue, but downgrading to 2.33.4 didn't help
@ralexandr @andrewlague @stephenh How did you downgrade?
Met same issue, but downgrading to 2.33.4 didn't help
@ralexandr @andrewlague @stephenh How did you downgrade?
npm i -D [email protected]
and then npm run apollo:push:dev
(i have "scripts": { "apollo:push:dev": "env-cmd --silent -f ./.env apollo service:push --variant=development", ... }
inside my package.json)
Pinning apollo
to 2.33.4
and apollo-language-server
to 1.26.3
worked for me
@Effanuel did you use npm i -g [email protected]
to pin it or your package.json
file? I still can't seem to get it to work.
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.
@Effanuel did you use
npm i -g [email protected]
to pin it or yourpackage.json
file? I still can't seem to get it to work.
Just add apollo with a veraion to devdeps
Is there any solution except downgrading nodejs and/or npm's and/or apollo's versions ?
@Effanuel did you use
npm i -g [email protected]
to pin it or yourpackage.json
file? I still can't seem to get it to work.
package.json:
"apollo": "2.33.4",
"apollo-language-server": "1.26.3",
On Node v16.8.0
, when I try to pin by adding versions to package.json
(I'm in a monorepo, this has been added to the root package.json
), I get the following error:
CLIError: Error in "Loading schema for core": Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
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?
Hi, we were stuck on this and was blocking us.
This is what worked for us:
- Pinned apollo to 2.33.4 (version before it broke) Then we kept having the "duplicate graphql" warning when running, so we:
- deleted node_modules
- deleted package-lock.json
- installed with "yarn" instead of "npm install"
Switching to yarn worked for us somehow, hope this can help.
This issue is caused by apollo-language-server
requiring @apollo/[email protected]
but @apollo/[email protected]
no longer working with graphql@14
(see https://github.com/apollographql/federation/issues/904). @apollo/federation
corrected this issue in 0.27.1 by requiring [email protected]
or higher as peer dependency, dropping the support for graphql@14
.
There are 2 options to fix this issue here:
- Either downgrade
@apollo/federation
insideapollo-language-server
to a version that still works withgraphql@14
- Or make all apollo-tooling packages fully compatible with
[email protected]
(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.
Any updates on this?
For us, downgrading to "2.33.4"
(no need for "apollo-language-server
) was enough to restore functionality. Still unclear though
I'm having the same issue I tried to use npx to use the latest then tried with 2.33.4
and also 2.20.0
and neither of them worked.
npx [email protected] schema:download --endpoint=https://graphql-pokeapi.graphcdn.app/graphql schema.json
Error: Cannot find module 'graphql/validation/rules/KnownArgumentNamesRule'
Require stack:
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/validate/preNormalization/tagDirective.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/validate/preNormalization/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/validate/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/composeAndValidate.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo-language-server/lib/providers/schema/file.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo-language-server/lib/providers/schema/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo-language-server/lib/project/base.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo-language-server/lib/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo/lib/Command.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo/lib/commands/service/download.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@oclif/config/lib/plugin.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@oclif/config/lib/config.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@oclif/config/lib/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@oclif/command/lib/command.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@oclif/command/lib/index.js
- C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/apollo/bin/run
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
at Function.Module._load (node:internal/modules/cjs/loader:774:27)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (C:/Users/joaof/AppData/Local/npm-cache/_npx/4f744a7352cbb6ab/node_modules/@apollo/federation/dist/composition/validate/preNormalization/tagDirective.js:6:34)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Module.require (node:internal/modules/cjs/loader:1013:19)
Okay made it work guys, using the latest version of the package but using node 14.16.0
:
npx apollo schema:download --endpoint=https://graphql-pokeapi.graphcdn.app/graphql schema.json
The moment I changed node version with nvm everything worked 🙏
I've tried all of the above and this is still not working for me. Node is version 14.17.4
, installed apollo globally at version 2.33.4
, pinned Apollo in the app at the same version and "apollo-language-server": "1.26.3",
Having this issue all of a sudden as well. Tried pinning apollo
and apollo-language-server
as specified above but no luck.
Got tired of waiting and the proposed fixes didn't work for me, so I switched to graphql-code-generator.
Differences:
- generates the code all in one file instead of different files (not really a pro or con)
- generates all the hooks for you which is actually unreal (definitely a pro, makes the hooks so much smaller without plugging in all the generics manually)
Edit: I think I've got a good configuration now: I've moved the gql
tag stuff into something.gql
files, pointed the apollo.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
I've added the following postinstall script to the scripts section of my package.json
and it work for me and my co-worker:
"postinstall": "rm -r node_modules/apollo-language-server/node_modules/graphql"
I had the same issue with our CI workflow and the downgrading didn't help.
But installing graphql helps npm install -g graphql
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.
How is this not getting more traction?
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 via apollo-boost
. We did manage to get the CLI to work for a few months with the following combination of explicit dependencies (dev and otherwise):
-
[email protected]
(for basevue-apollo
installation) -
[email protected]
(for basevue-apollo
installation) -
[email protected]
-
[email protected]
(added later to configure the in-memory cache) -
[email protected]
(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 use npx 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.
I solved putting "graphql" in peerDependencies in package.json
@OuthBack do you mind giving more contexto to how you solved this issue? thanks :D
@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.