我正在尝试安装 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: [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.
删除完整的初始化项目,然后执行这些命令:
npm init -y
npm install express express-graphql
npm install graphql
尝试在
express-graphql
之前安装graphql
。它有效。
卸载 graphql 模块(如果存在)。然后使用一个命令安装它们:
npm install graphql express-graphql
删除 package.json、package.lock.json 和节点模块。
再次初始化 npm
现在,首先从 npm 下载 express-graphql(在应用程序中下载任何其他 npm 包之前)
这些步骤解决了我的问题
我使用以下方法生成我的应用程序:
npx express-generator <projectName>
为了解决这个问题,我只是做了:
npm un express graphql
我已经安装然后运行的模块:
npm i express-graphql graphql express
按照这个顺序对我有用。
按这些顺序安装 npm 安装 express-graphql graphql express
如果你尝试在 graphql 之后安装 express-graphql - 它会创建冲突并且你会在控制台中看到错误。 根据 graphql 规范,你应该使用下一个安装模块顺序,就像在这个命令中一样:
npm install express express-graphql graphql --save
要修复问题提到的错误,您应该:
你能尝试删除你的 package-lock.json 文件吗?根据 github 问题
npm install express-graphql --save --force
对我有用。
我删除了 package-lock.json 并运行:
npm install express-graphql graphql --save
对我有用
像其他答案一样,首先删除 graphql via
npm remove graphql
现在安装 express-graphql as
npm install express-graphql
对我有用。
我安装了
graphql
然后express-graphql
,然后npm i express --force
第 1 步:删除
package.json
、package-lock.json
、node_modules
并重新开始。
第 2 步:
npm install express express-graphql graphql --save
显然按该顺序安装包是有效的。命令是从
GraphQL
文档中复制的。
https://graphql.org/graphql-js/running-an-express-graphql-server/
先安装
express-graphql
再安装express
.