Unable to install express-graphql

Unable to install express-graphql


9

I’m trying to install express-graphql but getting this error. Please, help!

npm install --save express-graphql 
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/graphql
npm ERR!   graphql@"^16.2.0" from the root project 
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer graphql@"^14.7.0 || ^15.3.0" from [email protected]
npm ERR! node_modules/express-graphql
npm ERR!   express-graphql@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Share

2

  • Same error. Did you find a solution?

    – thelearner

    Feb 19, 2022 at 21:46

  • I am facing a similar problem.

    – codemt

    Apr 10 at 5:25

14 Answers
14

Reset to default


15

Delete the full initialized project then run the following:

npm init -y
npm install express express-graphql
npm install graphql

You should install express-graphql before graphql.

Share


6

Uninstall graphql module if it’s present. Then install both of them with one command:

npm install graphql express-graphql

Share


3

I generated my app using:

npx express-generator <projectName>

and to solve the issue, I just did:

npm un express graphql

which where modules that I had already installed and then ran:

npm i express-graphql graphql express 

in that order worked for me.

Share


2

  1. Delete package.json, package-lock.json, & node_modules.
  2. Initialize npm again.
  3. Now, install express-graphql with npm at first (install before any other package in the app).

These steps solve my problem.

Share


1

Install in this order:

npm install express-graphql graphql express

Share


1

If you try to install express-graphql after graphql, it creates the conflict and that errors you see in the console.
According to GraphQL spec, you should use the following modules installation order:

npm install express express-graphql graphql --save

To fix the issues, you should:

  1. Remove graphql
  2. Install express-graphql
  3. Install graphql

Share


0

npm install express-graphql --save --force

works for me.

Share


0

I installed graphql then express-graphql, then npm i express --force

Share


0

STEP 1: Delete package.json, package-lock.json, node_modules and start again.

STEP 2: npm install express express-graphql graphql --save

Apparently installing packages in that order works. Command is copied from GraphQL docs.
https://graphql.org/graphql-js/running-an-express-graphql-server/

Share


0

Install express-graphql before installing express.

Share

1

  • ? The OP just failed to install express-graphql, so how he will install before something else ?

    – Elikill58

    Mar 8, 2022 at 9:06


0

Can you try deleting package-lock.json? It may help as per the github issue.

Share


0

I deleted package-lock.json and ran

npm install express-graphql graphql --save

It worked for me.

Share


0

As stated in the other answers, first remove graphql via:

npm remove graphql

Now install express-graphql with this command:

npm install express-graphql

It works for me.

Share


0

install express-graphql with yarn

  1. install yarn npm install --global yarn
  2. install dependencieyarn add express-graphql
  3. be happy!

Share

New contributor

DanyJerez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



Not the answer you're looking for? Browse other questions tagged

or ask your own question.

Leave a Reply

Your email address will not be published. Required fields are marked *