简体   繁体   English

安装或升级前如何知道 npm package 与 Angular 版本的兼容性?

[英]How to know npm package compatibility with Angular version prior install or upgrade?

I am planning to upgrade existing project from Angular 4 to Angular 7. I have 8-12 packages (other than angular lib) used in project.我计划将现有项目从 Angular 4 升级到 Angular 7。我有 8-12 个包(angular lib 除外)在项目中使用。 How do I know in advance whether package is compatible with Angular 7?怎么提前知道package是否兼容Angular 7? Below are the packages I am using in Angular 4.以下是我在 Angular 4 中使用的包。

"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
"angular-4-data-table-bootstrap-4": "^0.2.0",
"angular2-multiselect-dropdown": "^2.4.0",
"classlist.js": "^1.1.20150312",
"core-js": "^2.4.1",
"file-saver": "^1.3.3",
"geolib": "^2.0.24",
"intl": "^1.2.5",
"mydatepicker": "^2.6.3",
"ng-pick-datetime": "^5.0.0-beta.10",
"ng2-filter-pipe": "^0.1.10",
"ngx-chips": "^1.6.5",
"ngx-inactivity": "^1.0.1",
"ngx-loading": "^1.0.8",
"ngx-order-pipe": "^1.1.0",
"ngx-pagination": "^3.0.1",
"rxjs": "^5.4.2",
"web-animations-js": "^2.3.1",
"xlsx": "^0.11.14",
"xlsx-style": "^0.8.13",
"zone.js": "^0.8.14"

您可以按照guide和步骤将应用程序升级到angular7。此外,还可以通过运行,

npm audit fix

You should check one by one all these packages on github, open the package.json file for each of them and check the peer-dependencies property for each of them. 您应该在github上一一检查所有这些软件包,为每个软件包打开package.json文件,并为每个软件包检查peer-dependencies属性。

For example, angular2-modal package.json looks like this: 例如, angular2-modal package.json看起来像这样:

 ....
 "peerDependencies": {
    "@angular/core": "^2.1.1",
    "@angular/common": "^2.1.1"
 },
 ....

This means it won't work with any version of angular > 2. 这意味着它将不适用于angular> 2的任何版本。

By the way, you are lucky because npm and yarn will do the dirty job for you. 顺便说一下,您很幸运,因为npmyarn将为您完成肮脏的工作。 You can just update your angular version and if some peer dependency is not met, then the package manager will alert you with a warning. 您可以只更新角度版本,如果不满足某些同级依赖关系,则程序包管理器将警告您。

UNMET PEER DEPENDENCY angular-animate@^1.5.0 +-- 未知的对等关系angular-animate@^1.5.0 +-

UNMET PEER DEPENDENCY angular-aria@^1.5.0 +-- angular-material@1.0.6 + 未知的对等关系angular-aria@^1.5.0 +-angular-material@1.0.6 +

UNMET PEER DEPENDENCY angular-messages@^1.5.0 `-- mdi@1.4.57` 未知的对等关系angular-messages@^1.5.0`-mdi @ 1.4.57`

and you can fix them package by package 您可以逐包修复它们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM