@angular/core 更新期间出错:不兼容的对等依赖项

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

我的目标是将现有的 Angular 版本更新为较新的版本,特别是针对版本 17.3.0。但是,我在更新过程中遇到了不兼容的对等依赖项问题。以下是我尝试解决此问题的四个命令。

  1. nvm 列表
tio@MacBook-Air MySites % nvm list
->     v16.13.2
       v16.14.0
        v20.0.0
       v20.11.1
         system
default -> 16.13.2 (-> v16.13.2)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v20.11.1) (default)
stable -> 20.11 (-> v20.11.1) (default)
lts/* -> lts/iron (-> v20.11.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2 (-> N/A)
lts/hydrogen -> v18.19.1 (-> N/A)
lts/iron -> v20.11.1
tio@MacBook-Air MySites % nvm alias default node

default -> node (-> v20.11.1)
tio@MacBook-Air MySites % node -v
v20.11.1
  1. ng 更新@Angular/[电子邮件受保护]
tio@MacBook-Air MySites % ng update @angular/[email protected]

The installed Angular CLI version is outdated.

Installing a temporary Angular CLI versioned 17.3.7 to perform the update.

✔ Packages successfully installed.

Using package manager: npm

Collecting installed dependencies...

Found 22 dependencies.

Fetching dependency metadata from registry...

Updating multiple major versions of '@angular/core' at once is not supported. Please migrate each major version individually.

Run 'ng update @angular/core@16' in your workspace directory to update to latest '16.x' version of '@angular/core'.

For more information about the update process, see https://update.angular.io/?v=15.0-16.0
  1. ng更新@angular/core@16
tio@MacBook-Air MySites % ng update @angular/core@16
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 16.2.14 to perform the update.
✔ Packages successfully installed.
Using package manager: npm
Collecting installed dependencies...
Found 22 dependencies.
Fetching dependency metadata from registry...
    Updating package.json with dependency @angular/compiler-cli @ "16.2.12" (was "15.2.10")...
    Updating package.json with dependency @angular/animations @ "16.2.12" (was "15.2.10")...
    Updating package.json with dependency @angular/common @ "16.2.12" (was "15.2.10")...
    Updating package.json with dependency @angular/compiler @ "16.2.12" (was "15.2.10")...
    Updating package.json with dependency @angular/core @ "16.2.12" (was "15.2.10")...
    Updating package.json with dependency @angular/forms @ "16.2.12" (was "15.2.10")...
    Updating package.json with dependency @angular/platform-browser @ "16.2.12" (was "15.2.10")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "16.2.12" (was "15.2.10")...
    Updating package.json with dependency @angular/router @ "16.2.12" (was "15.2.10")...
    Updating package.json with dependency zone.js @ "0.13.3" (was "0.12.0")...
UPDATE package.json (1047 bytes)
✔ Packages successfully installed.
** Executing migrations of package '@angular/core' **

❯ In Angular version 15.2, the guard and resolver interfaces (CanActivate, Resolve, etc) were deprecated.
  This migration removes imports and 'implements' clauses that contain them.
  Migration completed (No changes made).

❯ As of Angular v16, the `moduleId` property of `@Component` is deprecated as it no longer has any effect.
  Migration completed (No changes made).
  1. ng 更新@Angular/[电子邮件受保护]
tio@MacBook-Air MySites % ng update @angular/[email protected]
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 17.3.7 to perform the update.
✔ Packages successfully installed.
Using package manager: npm
Collecting installed dependencies...
Found 22 dependencies.
Fetching dependency metadata from registry...
                  Package "@angular-devkit/build-angular" has an incompatible peer dependency to "@angular/compiler-cli" (requires "^15.0.0" (extended), would install "17.3.0").
                  Package "@angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=4.8.2 <5.0", would install "5.4.5").
✖ 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 "/private/var/folders/ct/xl1gnlvx39n4cqvdxk7y4m1c0000gn/T/ng-BxohLZ/angular-errors.log" for further details.

..角度误差.log

[error] Error: 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.
    at _validateUpdatePackages (/private/var/folders/ct/xl1gnlvx39n4cqvdxk7y4m1c0000gn/T/angular-cli-packages-ROEySj/node_modules/@angular/cli/src/commands/update/schematic/index.js:188:15)
    at /private/var/folders/ct/xl1gnlvx39n4cqvdxk7y4m1c0000gn/T/angular-cli-packages-ROEySj/node_modules/@angular/cli/src/commands/update/schematic/index.js:698:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async callRuleAsync (/private/var/folders/ct/xl1gnlvx39n4cqvdxk7y4m1c0000gn/T/angular-cli-packages-ROEySj/node_modules/@angular-devkit/schematics/src/rules/call.js:77:18)

为了尝试解决问题,我执行了以下命令:

tio@MacBook-Air MySites % ng update codelyzer@latest
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 15.2.11 to perform the update.
✔ Packages successfully installed.
Using package manager: npm
Collecting installed dependencies...
Found 22 dependencies.
Package 'codelyzer' is not a dependency.
angular angular-upgrade
1个回答
0
投票

为什么不删除 package.json 中的所有角度依赖性并执行新安装

© www.soinside.com 2019 - 2024. All rights reserved.