angular - Npm install 强制在升级到 Angular 7 后自己安装对等依赖项
问题描述
我最近将我的 Angular 应用程序从 6 升级到了 7。当我执行 npm install 时,angular cli 建议您自己安装对等依赖项。当我尝试通过以下命令安装对等依赖项时,例如:
npm install @angular/common@^7.0.0
它在依赖项部分添加了一个条目。所以当我一一安装时,会在依赖项下添加相应包的条目。所以最后我在两个地方得到了相同的包条目。那有意义吗。我做错什么了吗。我的理解是,对等依赖项仅在发布包时使用,所以我可以忽略警告是对的还是我需要安装所有对等依赖项
原始包.json:
{
"name": "@wtw/toolkit",
"version": "44.0.5",
"license": "MIT",
"dependencies": {
"@angular/cli": "^7.0.4",
"deep-diff": "1.0.2",
"moment": "^2.22.2",
"ng-click-outside": "^4.0.0"
},
"peerDependencies": {
"@angular/common": "^7.0.0",
"@angular/compiler": "^7.0.0",
"@angular/core": "^7.0.0",
"@angular/forms": "^7.0.0",
"@angular/http": "^7.0.0",
"@angular/platform-browser": "^7.0.0",
"@angular/platform-browser-dynamic": "^7.0.0",
"@angular/router": "^7.0.0",
"core-js": "^2.5.7",
"rxjs": "^6.3.3",
"zone.js": "^0.8.26"
}
}
运行 npm install 后,我收到以下警告消息:
npm WARN @wtw/toolkit@44.0.5 requires a peer of @angular/common@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @wtw/toolkit@44.0.5 requires a peer of @angular/compiler@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @wtw/toolkit@44.0.5 requires a peer of @angular/core@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @wtw/toolkit@44.0.5 requires a peer of @angular/forms@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @wtw/toolkit@44.0.5 requires a peer of @angular/http@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @wtw/toolkit@44.0.5 requires a peer of @angular/platform-browser@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @wtw/toolkit@44.0.5 requires a peer of @angular/platform-browser-dynamic@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @wtw/toolkit@44.0.5 requires a peer of @angular/router@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @wtw/toolkit@44.0.5 requires a peer of core-js@^2.5.7 but none is installed. You must install peer dependencies yourself.
npm WARN @wtw/toolkit@44.0.5 requires a peer of zone.js@^0.8.26 but none is installed. You must install peer dependencies yourself.
npm WARN ng-click-outside@4.0.0 requires a peer of @angular/common@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng-click-outside@4.0.0 requires a peer of @angular/core@>=6.0.0 but none is installed. You must install peer dependencies yourself.
我的新 package.json 想要
{
"name": "@wtw/platform",
"version": "44.0.15",
"license": "MIT",
"dependencies": {
"@angular/core": "^7.0.1",
"@ngx-translate/core": "^11.0.0",
"@ngx-translate/http-loader": "4.0.0",
"@types/google.analytics": "0.0.39",
"@wtw/toolkit": "44.0.5",
"bootstrap": "4.1.3",
"jsoneditor": "^5.24.7",
"ng2-file-upload": "^1.3.0",
"ngx-bootstrap": "3.0.1",
"ngx-cookie-service": "^1.0.10",
"ngx-jsoneditor": "^0.1.1",
"ngx-perfect-scrollbar": "6.3.1"
},
"peerDependencies": {
"@angular/core": "^7.0.1",
"jquery": "^3.3.1",
"@angular/animations": "^7.0.1",
"popper.js": "^1.14.3",
"@angular/compiler": "^7.0.1",
"@angular/common": "^7.0.1",
"@angular/forms": "^7.0.1",
"@angular/http": "^7.0.1",
"@angular/platform-browser": "^7.0.1",
"@angular/platform-browser-dynamic": "^7.0.1",
"@angular/router": "^7.0.1",
"core-js": "^2.5.7",
"rxjs": "^6.3.3",
"zone.js": "^0.8.26"
}
}
解决方案
推荐阅读
- javascript - jsx中无法识别布尔值?
- jdbc - 来自 Google Apps 脚本的 Jdbc 连接错误
- mysql - MySql安装数据库初始化错误
- python - 如何在 Python 中创建可重用函数
- python - 为什么 SymPy 的 factorint 函数会占用这么多 RAM,为什么关闭缓存不能修复它?
- c# - 调用 .NET RESTful api 时系统会创建一个 api 实例吗?
- json - 在Python中将json字符串转换为spark中的数据框
- passenger - 使用 nginx 的 FreeBSD 11.2 乘客失败
- java - 有没有办法在所有后代阶段完成后执行一个动作?
- java - 如果应用程序关闭,向用户显示警报?