我正在尝试从 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!
您需要了解 npm 依赖项如何工作。在 agm core 的 package.json 中,您将看到使用了 Angular ^9.1.0。因此,您需要运行相同或更高版本的 Angular 9 才能成功升级。
但是,看起来您的地图包仅支持 Angular 最高版本 10。考虑到 Angular 即将发布版本 18,您可能需要放弃旧包以采用更新的实现。
在 package.json 中,将所有 Angular 组件的版本更新到 9.1.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
)。是的,这些是相同的主要版本,但语义版本不同。
您应该能够通过执行以下两项操作之一来解决此问题:
@agm/core
的版本,其具有 ^9.1.13
的语义版本 @angular/common
。^9.0.0
。如果
ng update
正在为您执行此操作,您可以随时提供覆盖。
这样做,将覆盖任何包中对 @angular/common
的
ALL引用,对于 Angular,这可能就是你想要的。
{
"overrides": {
"@angular/common": "^9.1.13"
}
}
对于其他软件包,这可能不是您想要的,在这种情况下,您可以仅针对该软件包进行覆盖:
{
"overrides": {
"@org/package": {
"@other/package": "^1.2.3"
}
}
}