当尝试使用npm i命令安装npm包时,我得到了以下异常:
我尝试重新安装Node.js包,并使用以下方法将代理设置为关闭:
set HTTP_PROXY=
set HTTPS_PROXY=
问题仍然存在。我哪里做错了?
更新:
执行以下命令时:
npm install --legacy-peer-deps
系统显示如下错误:
当尝试使用npm i命令安装npm包时,我得到了以下异常:
我尝试重新安装Node.js包,并使用以下方法将代理设置为关闭:
set HTTP_PROXY=
set HTTPS_PROXY=
问题仍然存在。我哪里做错了?
更新:
执行以下命令时:
npm install --legacy-peer-deps
系统显示如下错误:
当前回答
重置package-lock。Json一直都很适合我:
git checkout -- package-lock.json
细节: 在更新遗留项目的所有包时,我经常遇到这种情况——我强烈不建议使用npm审计fix或npm I——force。删除包锁。Json也并不总是适用于我。回滚到包的工作版本。Json +包锁。Json和添加包对我来说是最安全、最快的变体。
其他回答
最快的解决方案:npm install——legacy-peer-deps
解释:
在npm版本3到6中,peerDependencies不会自动安装,如果在树中发现无效的peer dependency版本,将会发出警告。从npm v7开始,默认安装了peerDependencies。 npm docs: peerDependencies
你的依赖包含一些peerDependencies,这些peerDependencies与根项目的依赖冲突。
正如npm ERR日志中描述的那样。
我只是更新了我的Node.js,它为我工作:
node -v
输出:
V xxxx
And:
sudo npm install -g n
(使用此命令安装稳定节点release)
sudo n stable
您可以使用显示此错误的两种方式安装包
ERESOLVE unable to resolve dependency tree
使用npm Install并使用——legacy-peer-deps安装包
npm install --save --legacy-peer-deps
这是两个命令的组合 a.在npm config中设置legacy-peer-deps为true NPM配置设置为true b.现在使用npm install安装包 npm安装
Use
npm install --legacy-peer-deps
这对我很管用。
首先我尝试了
npm install
它给了我一个错误,无法解决依赖树,根据这个命令的帮助信息,
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.
我尝试了这个命令:
npm install --legacy-peer-deps
这解决了我的问题。