无法安装express-graphql

Udi*_*dav 8 node.js npm graphql express-graphql

我正在尝试安装express-graphql,但出现此错误。请帮忙!

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.
Run Code Online (Sandbox Code Playgroud)

小智 17

删除完整的初始化项目,然后运行以下命令:

npm init -y
npm install express express-graphql
npm install graphql
Run Code Online (Sandbox Code Playgroud)

您应该express-graphql先安装graphql


小智 5

graphql如果存在模块,请将其卸载。然后用一个命令安装它们:

npm install graphql express-graphql
Run Code Online (Sandbox Code Playgroud)


Saj*_*ran 1

你可以尝试删除package-lock.json吗?根据github 问题,它可能会有所帮助。