简体   繁体   English

无法安装 express-graphql

[英]unable to install express-graphql

I am trying to install express-graphql but getting this error.Please help我正在尝试安装 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.

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尝试在 graphql 之前安装 express-graphql 它可以工作

  1. Delete package.json, package.lock.json, & node modules.删除 package.json、package.lock.Z466DEEC76ECDF5FCA6D38571F6324 模块。

  2. Initialize npm again再次初始化 npm

  3. Now, First download express-graphql from npm ( Download before any other npm package in app )现在,首先从 npm 下载 express-graphql(在应用程序中的任何其他 npm package 之前下载)

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根据github 问题,您可以尝试删除您的package-lock.json文件吗?

install express-graphql before installing express在安装 express 之前安装 express-graphql

npm install express-graphql --save --force

works for me.为我工作。

I deleted the package-lock.json and ran:我删除了 package-lock.json 并运行:

npm install express-graphql graphql --save 

It worked for me它对我有用

Uninstall graphql module if it's present.如果 graphql 模块存在,请卸载它。 then install both of them with one command:然后使用一个命令安装它们:

npm install graphql express-graphql

Like the other answers, first remove the graphql via像其他答案一样,首先通过删除 graphql

npm remove graphql

Now intall express-graphql as现在将 express-graphql 安装为

npm install express-graphql

It works for me.这个对我有用。

I installed graphql then express-graphql , then npm i express --force我安装了graphql然后express-graphql ,然后是npm i express --force

install in these order npm install express-graphql graphql express按照这些顺序安装 npm 安装 express-graphql graphql express

If u try to install express-graphql after graphql - it creates confilct and that errors u see in the console.如果您尝试在 graphql 之后安装 express-graphql - 它会创建冲突并且您会在控制台中看到错误。 According to graphql spec u should use next installation modules order like in this command:根据 graphql 规范,您应该使用下一个安装模块顺序,如下命令所示:

npm install express express-graphql graphql --save

To fix isshues mentioned errors u should:要修复问题提到的错误,您应该:

  1. Remove graphql删除 graphql
  2. Install express-graphql安装 express-graphql
  3. Install graphql安装 graphql

STEP 1: Delete package.json, package-lock.json, node_modules and start again.第 1 步:删除 package.json、package-lock.json、node_modules 并重新开始。

STEP 2: npm install express express-graphql graphql --save第 2 步:npm 安装 express express-graphql graphql --save

Apparently installing packages in that order works.显然按该顺序安装软件包是可行的。 Command is copied from GraphQL docs.命令复制自 GraphQL 文档。 https://graphql.org/graphql-js/running-an-express-graphql-server/ https://graphql.org/graphql-js/running-an-express-graphql-server/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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