Mat*_*att 11 node.js npm angular
我正在尝试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.
Run Code Online (Sandbox Code Playgroud)
我将 node.js 更新到最新推荐的 LTS 版本,当前版本为 14。这就是导致问题的原因。
我尝试使用--forceand --legacy-peer-deps,但这不起作用。
解决方案是将node版本降级到12。
这是要修复的复制/粘贴解决方案。复制所有这些代码并粘贴到项目根目录的终端中。(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
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?
package-lock.json文件node_modules目录(-rfv=递归、强制、详细)nvm(节点版本管理器)nvmnvmnvm安装节点v12npm安装软件包| 归档时间: |
|
| 查看次数: |
33152 次 |
| 最近记录: |