[英]npm install - ERESOLVE unable to resolve dependency tree
我正在嘗試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.
我將 node.js 更新為最新推薦的 LTS 版本,目前是版本 14。這就是導致問題的原因。
我嘗試使用--force
和--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
這里發生了什么?
package-lock.json
文件node_modules
目錄( -rfv
= recursive, force, verbose)nvm
(節點版本管理器)nvm
nvm
nvm
安裝 node v12npm
安裝軟件包嘗試npm install --legacy-peer-deps
。 這對我有用。 但首先確保刪除package-lock.json
和node_modules
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.