将角度 8 更新为 9

问题描述 投票:0回答:2

我正在尝试从 8 点更新到 9 点,我得到了:

Using package manager: 'npm'
Collecting installed dependencies...
Found 85 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular/material @ "9.2.4" (was "8.2.3")...
    Updating package.json with dependency @angular/cdk @ "9.2.4" (was "8.2.3")...
UPDATE package.json (6742 bytes)
⠸ Installing packages...npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @agm/[email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^9.1.13" from the root project
npm ERR!   peer @angular/common@"^9.0.0" from @angular-material-extensions/[email protected]
npm ERR!   node_modules/@angular-material-extensions/password-strength
npm ERR!     @angular-material-extensions/password-strength@"^6.0.0" from the root project
npm ERR!   15 more (@angular/flex-layout, @angular/forms, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^6.0.0 || ^7.0.0 || ^8.0.0" from @agm/[email protected]
npm ERR! node_modules/@agm/core
npm ERR!   @agm/core@"^1.0.0" from the root project
npm ERR!   peer @agm/core@"^1.0.0-beta.7" from @agm/[email protected]
npm ERR!   node_modules/@agm/js-marker-clusterer
npm ERR!     @agm/js-marker-clusterer@"^1.1.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   peer @angular/common@"^6.0.0 || ^7.0.0 || ^8.0.0" from @agm/[email protected]
npm ERR!   node_modules/@agm/core
npm ERR!     @agm/core@"^1.0.0" from the root project
npm ERR!     peer @agm/core@"^1.0.0-beta.7" from @agm/[email protected]
npm ERR!     node_modules/@agm/js-marker-clusterer
npm ERR!       @agm/js-marker-clusterer@"^1.1.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 

当我跑步时

NG_DISABLE_VERSION_CHECK=1 npx @angular/cli@9 update @angular/material@9
我明白了:

Using package manager: 'npm'
Collecting installed dependencies...
Found 85 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular/material @ "9.2.4" (was "8.2.3")...
    Updating package.json with dependency @angular/cdk @ "9.2.4" (was "8.2.3")...
UPDATE package.json (6742 bytes)
⠸ Installing packages...npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @agm/[email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^9.1.13" from the root project
npm ERR!   peer @angular/common@"^9.0.0" from @angular-material-extensions/[email protected]
npm ERR!   node_modules/@angular-material-extensions/password-strength
npm ERR!     @angular-material-extensions/password-strength@"^6.0.0" from the root project
npm ERR!   15 more (@angular/flex-layout, @angular/forms, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^6.0.0 || ^7.0.0 || ^8.0.0" from @agm/[email protected]
npm ERR! node_modules/@agm/core
npm ERR!   @agm/core@"^1.0.0" from the root project
npm ERR!   peer @agm/core@"^1.0.0-beta.7" from @agm/[email protected]
npm ERR!   node_modules/@agm/js-marker-clusterer
npm ERR!     @agm/js-marker-clusterer@"^1.1.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   peer @angular/common@"^6.0.0 || ^7.0.0 || ^8.0.0" from @agm/[email protected]
npm ERR!   node_modules/@agm/core
npm ERR!     @agm/core@"^1.0.0" from the root project
npm ERR!     peer @agm/core@"^1.0.0-beta.7" from @agm/[email protected]
npm ERR!     node_modules/@agm/js-marker-clusterer
npm ERR!       @agm/js-marker-clusterer@"^1.1.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
angular angular8 angular9 agm-core
2个回答
1
投票

您需要了解 npm 依赖项如何工作。在 agm core 的 package.json 中,您将看到使用了 Angular ^9.1.0。因此,您需要运行相同或更高版本的 Angular 9 才能成功升级。

但是,看起来您的地图包仅支持 Angular 最高版本 10。考虑到 Angular 即将发布版本 18,您可能需要放弃旧包以采用更新的实现。

在 package.json 中,将所有 Angular 组件的版本更新到 9.1.0 或更高版本。


0
投票

您可以通过了解错误来修复依赖项。让我们看看第一个依赖项告诉我们什么:

npm ERR! While resolving: @agm/[email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^9.1.13" from the root project
npm ERR!   peer @angular/common@"^9.0.0" from @angular-material-extensions/[email protected]
npm ERR!   node_modules/@angular-material-extensions/password-strength
npm ERR!     @angular-material-extensions/password-strength@"^6.0.0" from the root project
npm ERR!   15 more (@angular/flex-layout, @angular/forms, ...)
  • @agm/core
    package.json
    中的语义版本格式不正确。
    • 它正在询问
      ^9.0.0
       的版本 
      @angular/common
    • 您正在提供
      ^9.1.13
      (我认为是胡萝卜,因为您没有提供
      package.json
      )。

是的,这些是相同的主要版本,但语义版本不同。

您应该能够通过执行以下两项操作之一来解决此问题:

  1. 查找
    @agm/core
    的版本,其具有
    ^9.1.13
    的语义版本
    @angular/common
  2. 将您的语义版本更改为
    ^9.0.0

如果

ng update
正在为您执行此操作,您可以随时提供覆盖。

这样做,将覆盖任何包中对 @angular/common

ALL
引用,对于 Angular,这可能就是你想要的。

{
  "overrides": {
    "@angular/common": "^9.1.13"
  }
}

对于其他软件包,这可能不是您想要的,在这种情况下,您可以仅针对该软件包进行覆盖:

{
  "overrides": {
    "@org/package": {
      "@other/package": "^1.2.3"
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.