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

Error: Cannot find module 'graphql' apollo-server-express v2.10.1 #4949

Closed
FlavioAPareja opened this issue Feb 23, 2021 · 7 comments
Closed

Comments

@FlavioAPareja
Copy link

Suttendly we started to get this error and just fixed with a npm i graphql

Graphql packages:

  • "apollo-server-express": "2.10.1"
  • "graphql-parse-fields": "1.2.0"
  • "graphql-tools": "4.0.7",

Node version: v8.4.0

after run npm install and initialize the express server we got this error:

0|api-prov | Error: Cannot find module 'graphql'
0|api-prov |     at Function.Module._resolveFilename (module.js:489:15)
0|api-prov |     at Module.Hook._require.Module.require (/home/zcebjobs/.nvm/versions/node/v8.4.0/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:61:29)
0|api-prov |     at require (internal/module.js:11:18)
0|api-prov |     at Object.<anonymous> (/var/www/ceb-providers/core-api/node_modules/apollo-server-errors/dist/index.js:4:19)
0|api-prov |     at Module._compile (module.js:573:30)
0|api-prov |     at Object.Module._extensions..js (module.js:584:10)
0|api-prov |     at Module.load (module.js:507:32)
0|api-prov |     at tryModuleLoad (module.js:470:12)
0|api-prov |     at Function.Module._load (module.js:462:3)
0|api-prov |     at Module.require (module.js:517:17)
0|api-prov |     at Module.Hook._require.Module.require (/home/zcebjobs/.nvm/versions/node/v8.4.0/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
0|api-prov |     at require (internal/module.js:11:18)
0|api-prov |     at Object.<anonymous> (/var/www/ceb-providers/core-api/node_modules/apollo-server-core/dist/runHttpQuery.js:15:32)
0|api-prov |     at Module._compile (module.js:573:30)
0|api-prov |     at Object.Module._extensions..js (module.js:584:10)
0|api-prov |     at Module.load (module.js:507:32)
0|api-prov |     at tryModuleLoad (module.js:470:12)
0|api-prov |     at Function.Module._load (module.js:462:3)
0|api-prov |     at Module.require (module.js:517:17)
0|api-prov |     at Module.Hook._require.Module.require (/home/zcebjobs/.nvm/versions/node/v8.4.0/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
0|api-prov |     at require (internal/module.js:11:18)
0|api-prov |     at Object.<anonymous> (/var/www/ceb-providers/core-api/node_modules/apollo-server-core/dist/index.js:18:22)

The application is running with the latet version of PM2 :)

@glasser
Copy link
Member

glasser commented Feb 24, 2021

apollo-server-express expects graphql to be installed as a peer dependency, instead of installing it itself. (Though I believe npm v7 will install it for you since it treats peer dependencies differently.) So this is working as expected. Did you see any docs that told you to install apollo-server-express without also installing graphql?

(Also, apollo-server-express v2.10.1 is over a year old.)

@glasser glasser closed this as completed Feb 24, 2021
@jbsulli
Copy link

jbsulli commented Mar 3, 2021

Yes, the apollo-server-express npm module page mentions installing it without the graphql dep: https://www.npmjs.com/package/apollo-server-express

glasser added a commit that referenced this issue Mar 3, 2021
See #4949. This matches what we do in the docs site.

I have not done an exhaustive search across READMEs for more problems like this; PRs welcome.
@glasser
Copy link
Member

glasser commented Mar 3, 2021

Thanks, I've fixed that README (in git, npmjs will be fixed at next publish): 80a9747

If anyone motivated to look at all the READMEs in this repo for more npm install lines, I'm happy to review the output.

@AnirudhaGohokar
Copy link

Why did it suddenly started breaking?

@glasser
Copy link
Member

glasser commented Mar 12, 2021

@AnirudhaGohokar Likely due to npm v7 being released as "latest", which treats peer dependencies differently if you've started using it.

@MrSaints
Copy link

I just came across this. I believe the docs for https://github.com/apollographql/apollo-server/tree/main/packages/apollo-server-fastify, and perhaps others needs updating as well.

@glasser
Copy link
Member

glasser commented Mar 25, 2021

@MrSaints Thanks, updated that one and all others I found with git grep 'npm install' in b82c431

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants