我需要帮助解释NPM ERESOLVE错误消息



当我试图在刚刚克隆的项目上运行NPM安装时,收到了来自NPM的以下错误。有人能向我解释一下如何解释这个错误信息吗?我根本不确定npm抱怨的是哪个依赖项,也不确定它获取这些值的途径。我甚至不知道这个错误消息是否应该像堆栈跟踪一样从下往上读取。这是错误消息:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-code@0.3.0
npm ERR! Found: @types/react@17.0.3
npm ERR! node_modules/@types/react
npm ERR!   peerOptional @types/react@"^16.8.6 || ^17.0.0" from @material-ui/core@4.11.3
npm ERR!   node_modules/@material-ui/core
npm ERR!     @material-ui/core@"^4.11.0" from the root project
npm ERR!     peer @material-ui/core@"^4.0.0" from @material-ui/icons@4.9.1
npm ERR!     node_modules/@material-ui/icons
npm ERR!       @material-ui/icons@"4.9.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional @types/react@"^16.8.6" from @material-ui/icons@4.9.1
npm ERR! node_modules/@material-ui/icons
npm ERR!   @material-ui/icons@"4.9.1" from the root project
npm ERR!

我今天收到了这个错误消息。以下是我的发现。。。

问题:您的package.json中提到的一个或多个依赖项最近更新了它们的对等依赖项。因此,npm在解析依赖树时遇到冲突(甚至在下载包之前(

解决方案:确保";对等依赖关系";在";主要版本";

在您的情况下,@types/react@17.0.3package.json中提到了。但是@material-ui/icons@4.9.1需要@types/react@"^16.8.6〃;。

你可以升级@material-ui/icons

@material-ui/icons: "4.9.1" ---> @material-ui/icons: "^4.9.1"

或将反应类型降级为版本16

在Dockerfile中将节点版本更改为12.14.1,它将在中工作

FROM node:12.14.1-alpine

尝试删除package-lock.json文件和node_modules文件夹,然后再次运行npm i。或者你可以考虑使用纱线,因为它不会造成问题。

npm install --legacy-peer-deps

运行上面的命令而不是npm安装,你不会得到任何错误。

最新更新