[英]npm install - ERESOLVE unable to resolve dependency tree
I am trying to npm install
but getting this error.我正在尝试
npm install
但收到此错误。
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: webapp@21.0.0
npm ERR! Found: @angular/cdk@9.2.4
npm ERR! node_modules/@angular/cdk
npm ERR! @angular/cdk@"9.2.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/cdk@"8.2.3" from @angular/material@8.2.3
npm ERR! node_modules/@angular/material
npm ERR! @angular/material@"8.2.3" 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.
I updated node.js to the latest recommended LTS version which is currently version 14. This is what is causing the problem.我将 node.js 更新为最新推荐的 LTS 版本,目前是版本 14。这就是导致问题的原因。
I tried using --force
and --legacy-peer-deps
, but this didn't work.我尝试使用
--force
和--legacy-peer-deps
,但这没有用。
The solution is to downgrade the node version to 12.解决办法是降级node版本到12。
Here is a copy/paste solution to fix.这是要修复的复制/粘贴解决方案。 Copy all of this code and paste in the terminal at the root of your project.
复制所有这些代码并粘贴到项目根目录下的终端中。 (Where your
package.json
file that you are trying to install is.) (您尝试安装的
package.json
文件所在的位置。)
rm package-lock.json
rm -rfv node_modules
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 12
nvm use 12
npm i
What is happening here?这里发生了什么?
package-lock.json
filepackage-lock.json
文件node_modules
directory ( -rfv
= recursive, force, verbose)node_modules
目录( -rfv
= recursive, force, verbose)nvm
(Node Version Manager)nvm
(节点版本管理器)nvm
nvm
nvm
nvm
nvm
to install node v12nvm
安装 node v12npm
to install the packagesnpm
安装软件包try npm install --legacy-peer-deps
.尝试
npm install --legacy-peer-deps
。 This worked for me.这对我有用。 But first make sure you delete your
package-lock.json
and node_modules
.但首先确保删除
package-lock.json
和node_modules
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.