Unable to install express-graphql
Asked Answered
E

15

8

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.
Elaelaborate answered 4/1, 2022 at 6:40 Comment(2)
Same error. Did you find a solution?Forage
I am facing a similar problem.Levine
M
17

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.

Muskellunge answered 30/3, 2022 at 16:37 Comment(0)
T
5

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

npm install graphql express-graphql
Thumbtack answered 30/8, 2022 at 12:3 Comment(0)
S
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.

Shriner answered 3/7, 2022 at 18:55 Comment(0)
J
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.

Johnson answered 10/3, 2022 at 9:50 Comment(0)
P
1

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

Porphyrin answered 4/1, 2022 at 7:35 Comment(0)
L
1

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.

Luo answered 28/9, 2022 at 14:41 Comment(0)
S
1

Install in this order:

npm install express-graphql graphql express
Sarajane answered 3/1, 2023 at 9:43 Comment(0)
M
1

'express-graphql' is DEPRECTATED in favor of graphql-http!

Million answered 30/5 at 5:23 Comment(0)
A
0

Install express-graphql before installing express.

Attainable answered 8/3, 2022 at 6:37 Comment(1)
? The OP just failed to install express-graphql, so how he will install before something else ?Halation
A
0
npm install express-graphql --save --force

works for me.

Additive answered 16/4, 2022 at 12:31 Comment(0)
E
0

I deleted package-lock.json and ran

npm install express-graphql graphql --save

It worked for me.

Emigrant answered 23/6, 2022 at 9:22 Comment(0)
A
0

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

Askew answered 11/12, 2022 at 23:20 Comment(0)
S
0

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
Sludge answered 11/1, 2023 at 18:14 Comment(0)
N
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/

Noxious answered 20/1, 2023 at 22:34 Comment(0)
H
0

install express-graphql with yarn

  1. install yarn npm install --global yarn
  2. install dependencieyarn add express-graphql
  3. be happy!
Hoxsie answered 13/8, 2023 at 6:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.