如何将 angular 版本从 7 升级到 8?

How to upgrade angular version from 7 to 8?

运行 ng update @angular/cli @angular/core 我每次都会收到这个

Package "@angular/compiler-cli" has an incompatible peer dependency to "@angular/compiler" (requires "8.2.0-next.1", would install "8.1.1") Package "ag-grid-angular" has an incompatible peer dependency to "@angular/compiler-cli" (requires ">=2.1.x" (extended), would install "8.2.0-next.1").

Package "angular-calendar" has an incompatible peer dependency to "@angular/core" (requires ">=5.0.0 <7.0.0" (extended), would install "8.1.1").

Package "@angular/compiler-cli" has an incompatible peer dependency to "@angular/compiler" (requires "8.2.0-next.1" (extended), would install "8.1.1").

Package "angular-calendar" has an incompatible peer dependency to "@angular/common" (requires ">=5.0.0 <7.0.0" (extended), would install "8.1.1").

Package "angular-calendar" has an incompatible peer dependency to "@angular/animations" (requires ">=5.0.0 <7.0.0" (extended), would install "8.1.1").

我现在的环境是:

Angular CLI: 7.3.9
Node: 12.6.0
OS: win32 x64
Angular: 7.1.4
... common, compiler, compiler-cli, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.12.4
@angular-devkit/build-angular      0.12.4
@angular-devkit/build-optimizer    0.12.4
@angular-devkit/build-webpack      0.12.4
@angular-devkit/core               7.2.4
@angular-devkit/schematics         7.3.9
@angular/animations                7.2.15
@angular/cdk                       7.3.7
@angular/cli                       7.3.9
@angular/material                  7.2.0
@angular/material-moment-adapter   7.3.7
@ngtools/webpack                   7.2.4
@schematics/angular                7.3.9
@schematics/update                 0.13.9
rxjs                               6.5.2
typescript                         3.4.5
webpack                            4.28.4

您可能需要运行这个命令:

ng update --all --force

这种更新所有适用的 Angular 包。

至于其他第3方包如angular-calendar,您可能需要手动运行 npm命令将它们更新到支持Angular 8.[=的版本13=]

在检查您的第 3 方包时,您只需 运行 命令,它将 return 这些包的最新版本列表。

npm outdated

首先你应该按照更新指南中提到的步骤进行操作 https://update.angular.io/.

此外,当收到像您这样的错误时,您可能希望在命令前加上 --force 前缀,例如

ng update @angular/core @angular/cli --force