2

我在我的项目中使用 Angular 8,并想升级到 Angular 9。

我遵循升级指南,当我运行命令时: ng update @angular/core @angular/cli

我收到一条错误消息:

An unhandled exception occurred: 403 Forbidden - GET https://registry.npmjs.org/@angular%2fcli

更新:403 错误消失了,但现在我收到以下错误:

Package "@angular/core" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "codelyzer" has an incompatible peer dependency to "@angular/core" (requires ">=2.3.1 <8.0.0 || >7.0.0-beta <8.0.0" (extended), would install "9.0.1").
Package "@angular/compiler-cli" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/animations" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/forms" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/common" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/platform-server" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/compiler" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "codelyzer" has an incompatible peer dependency to "@angular/compiler" (requires ">=2.3.1 <8.0.0 || >7.0.0-beta <8.0.0" (extended), would install "9.0.1").
Package "@angular/service-worker" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/router" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/platform-browser-dynamic" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/platform-browser" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/http" has an incompatible peer dependency to "@angular/platform-browser" (requires "7.0.4" (extended), would install "9.0.1").

已解决: 我已将 tslib 添加到 package.json

4

2 回答 2

4

经历过同样的问题。

能够使用以下方法成功从 Angular 7 更新到 8:

ng update @angular/cli@8 @angular/core@8

但是,尝试使用以下方法从 Angular 8 更新到 9:

ng update @angular/cli@9 @angular/core@9

给了我这个错误:

Package "@angular/compiler-cli" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/animations" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/common" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/compiler" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/core" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/forms" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/platform-browser" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/platform-server" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/router" has a missing peer dependency of "tslib" @ "^1.10.0".
Package "@angular/service-worker" has a missing peer dependency of "tslib" @ "^1.10.0".

我通过添加tslibto devDependenciesin的建议版本解决了这个问题package.json

"devDependencies": {
    "tslib": "^1.10.0",
    ...
}
于 2020-09-10T06:48:08.853 回答
3

更新到 angular9 后,我遇到了同样的问题。首先我完全更新了angular8,然后更新到了angular9。

ng update @angular/cli@8 @angular/core@8

其次,我更新了以下命令。

ng update @angular/cli@9 @angular/core@9

请点击链接: 如何更新到 Angular9

于 2020-04-01T17:54:06.427 回答