unable to install express-graphql

Viewed 1645

I am 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: rest-api@1.0.0
npm ERR! Found: graphql@16.2.0
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 express-graphql@0.12.0
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.
8 Answers

Delete full Initialized project then

  1. npm init -y
  2. npm install express express-graphql
  3. npm install graphql

try installing express-graphql before graphql it work`s

  1. Delete package.json, package.lock.json, & node modules.

  2. Initialize npm again

  3. Now, First download express-graphql from npm ( Download before any other npm package in app )

These steps solve my problem

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.

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

npm install graphql express-graphql

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

install express-graphql before installing express

npm install express-graphql --save --force

works for me.

I deleted the package-lock.json and ran:

npm install express-graphql graphql --save 

It worked for me

Related