简体   繁体   中英

unable to install express-graphql

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.

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.

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

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

npm install graphql express-graphql

Like the other answers, first remove the graphql via

npm remove graphql

Now intall express-graphql as

npm install express-graphql

It works for me.

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

install in these order npm install express-graphql graphql express

If u try to install express-graphql after graphql - it creates confilct and that errors u see in the console. According to graphql spec u should use next installation modules order like in this command:

npm install express express-graphql graphql --save

To fix isshues mentioned errors u should:

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

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM