Node.js npm安装-ERESOLVE无法解析依赖关系树
我正在尝试Node.js npm安装-ERESOLVE无法解析依赖关系树,node.js,angular,npm,Node.js,Angular,Npm,我正在尝试npm安装,但出现此错误 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&q
npm安装
,但出现此错误
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.
我将node.js更新为最新推荐的LTS版本,当前版本为14。这就是造成问题的原因 我试着使用
--force
和--legacy peer deps
,但这不起作用
解决方案是将节点版本降级为12。
下面是一个要修复的复制/粘贴解决方案。复制所有这些代码并粘贴到项目根目录下的终端中。(您尝试安装的package.json
文件位于此处。)
这里发生了什么
包锁.json
文件节点\u模块
目录(-rfv
=递归、强制、详细)nvm
(节点版本管理器)nvm
nvm
nvm
安装节点v12npm
安装软件包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