从 Angular 9 升级到 Angular 10 时遇到问题

Posted

技术标签:

【中文标题】从 Angular 9 升级到 Angular 10 时遇到问题【英文标题】:Trouble upgrading from angular 9 to angular 10 【发布时间】:2020-10-16 09:20:08 【问题描述】:

我想更新我的 Angular 项目,我使用了以下命令。

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

但是在控制台中执行最后一个命令行后,它会抛出以下错误。

Your global Angular CLI version (10.0.0) is greater than your local
version (9.1.9). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
The installed local Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Using package manager: 'npm'
Collecting installed dependencies...
Found 40 dependencies.
Fetching dependency metadata from registry...
                  Package "@ng-select/ng-option-highlight" has an incompatible peer dependency to "@angular/core" (requires "^8.0.3" (extended), would install "10.0.0").
                  Package "@ng-select/ng-select" has an incompatible peer dependency to "@angular/forms" (requires ">=8.0.0 <9.0.0" 
(extended), would install "10.0.0").
                  Package "@ng-select/ng-option-highlight" has an incompatible peer dependency to "@angular/common" (requires "^8.0.3" (extended), would install "10.0.0").
× Migration failed: Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
  See "C:\Users\jfhh\AppData\Local\Temp\ng-riDjkX\angular-errors.log" for further details.

【问题讨论】:

那个错误似乎很清楚。你有什么不明白的? 【参考方案1】:

添加后缀--force可以消除不兼容的对等依赖错误 即使用以下命令

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

【讨论】:

以上是关于从 Angular 9 升级到 Angular 10 时遇到问题的主要内容,如果未能解决你的问题,请参考以下文章

编译 Angular 11(从 Angular 9 升级)应用程序时出错

角度从 8 升级到 9 - 纱线不兼容错误

升级到 9.0 和 angular 7 后修复 angular-redux/store

如何从 Angular 4 更新/升级到 Angular 5+

Angular 从 1.6.6 升级到 6 时出现 $Injector 错误

从 Angular 1 升级到 Angular 2 需要准备的步骤