首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >npm安装-强制和npm安装-遗留-对等-deps的区别是什么?

npm安装-强制和npm安装-遗留-对等-deps的区别是什么?
EN

Stack Overflow用户
提问于 2021-02-04 18:19:32
回答 1查看 8.7K关注 0票数 7

我正在尝试使用node_modules为一个项目安装npm install。但它失败了。

错误日志

代码语言:javascript
复制
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: my-first-app@0.0.0
npm ERR! Found: @angular/compiler@11.0.9
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"~11.0.0" from the root project
npm ERR!   peer @angular/compiler@"11.0.9" from @angular/compiler-cli@11.0.9
npm ERR!   node_modules/@angular/compiler-cli
npm ERR!     dev @angular/compiler-cli@"~11.0.0" from the root project
npm ERR!     peer @angular/compiler-cli@"^11.0.0" from @angular-devkit/build-angular@0.1100.7
npm ERR!     node_modules/@angular-devkit/build-angular
npm ERR!       dev @angular-devkit/build-angular@"~0.1100.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"11.1.2" from @angular/localize@11.1.2
npm ERR! node_modules/@angular/localize
npm ERR!   peerOptional @angular/localize@"^11.0.0" from @angular-devkit/build-angular@0.1100.7
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~0.1100.0" 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.
npm ERR! 
npm ERR! See /Users/amit/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/amit/.npm/_logs/2021-02-04T17_58_24_981Z-debug.log

日志建议使用npm install --forcenpm install --legacy-peer-deps

我想了解npm install --forcenpm install --legacy-peer-deps之间的基本区别。

另外,如果--force的性能优于--legacy-peer-deeps或反之亦然,那么使用哪一种更好呢?

任何建议/指示都是非常值得赞赏的。谢谢!

EN

回答 1

Stack Overflow用户

发布于 2022-09-30 11:13:03

两者之间的差异如下

--legacy-peer-deps:在安装时忽略所有peerDependencies,采用npm版本4的样式,直到版本6。

--strict-peer-deps:失败,并在遇到冲突的peerDependencies时中止安装过程。默认情况下,npm将导致由根项目的直接依赖关系引起的peerDependencies冲突崩溃。

即使磁盘上存在本地副本,--forces :也将强制npm获取远程资源。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66051520

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档