在我的 ASP.net MVC 项目中将 Angular 从 6 升级到 7 时出现问题,需要帮助

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

我有一个使用 Angular 框架 6 的 ASP.net MVC 项目。我尝试按照 https://update.angular.io/?l=3&v=6.1-7.0

的指南将 Angular 从 6 升级到 7

当我运行下面的命令时

cmd /C "set "NG_DISABLE_VERSION_CHECK=1" && npx @angular/cli@7 update @angular/cli@7 @angular/core@7"

我收到错误消息:

Your global Angular CLI version (7.3.10) is greater than your local
version (6.2.9). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
                  Package "@angular/platform-browser-dynamic" has a missing peer dependency of "@angular/compiler" @ "7.2.16".
                  Package "@angular/router" has a missing peer dependency of "@angular/platform-browser" @ "7.2.16".
                  Package "@angular/forms" has a missing peer dependency of "@angular/platform-browser" @ "7.2.16".
Incompatible peer dependencies found. See above.

如果我尝试

ng update @angular/[email protected] @angular/[email protected] --force

这是我得到的

Package "@angular/platform-browser-dynamic" has a missing peer dependency of "@angular/compiler" @ "7.2.16".
                  Package "@angular/forms" has a missing peer dependency of "@angular/platform-browser" @ "7.2.16".
                  Package "@angular/router" has a missing peer dependency of "@angular/platform-browser" @ "7.2.16".
    Updating package.json with dependency zone.js @ "0.8.29" (was "0.8.26")...
    Updating package.json with dependency rxjs @ "6.6.7" (was "6.2.2")...
    Updating package.json with dependency @angular/core @ "7.2.16" (was "6.1.10")...
    Updating package.json with dependency @angular/platform-browser-dynamic @ "7.2.16" (was "6.1.7")...
    Updating package.json with dependency @angular/common @ "7.2.16" (was "6.1.7")...
    Updating package.json with dependency @angular/forms @ "7.2.16" (was "6.1.7")...
    Updating package.json with dependency @angular/language-service @ "7.2.16" (was "6.1.7")...
    Updating package.json with dependency @angular/router @ "7.2.16" (was "6.1.7")...
UPDATE package.json (1802 bytes)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"^7.2.16" from the root project
npm ERR!   peer @angular/common@">=6.0.0-beta.0 <7.0.0" from @angular/[email protected]
npm ERR!   node_modules/@angular/cdk
npm ERR!     peer @angular/cdk@"6.4.7" from @angular/[email protected]
npm ERR!     node_modules/@angular/material
npm ERR!       @angular/material@"^6.1.0" from the root project
npm ERR!   9 more (@angular/forms, @angular/material, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! @angular/common@"^7.2.16" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/[email protected]
npm ERR! node_modules/@angular/core
npm ERR!   peer @angular/core@"7.2.16" from @angular/[email protected]
npm ERR!   node_modules/@angular/common
npm ERR!     @angular/common@"^7.2.16" 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 ERR! For a full report see:
npm ERR! C:\Users\rrao\AppData\Local\npm-cache\_logs\2023-12-21T19_57_25_233Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: C:\Users\rrao\AppData\Local\npm-cache\_logs\2023-12-21T19_57_25_233Z-debug-0.log
Package install failed, see above.
angular upgrade
1个回答
0
投票

尝试使用

--force
单独运行更新:

ng 更新@angular/[电子邮件受保护] --force

ng 更新@angular/[电子邮件受保护] --force

ng 更新@angular/[电子邮件受保护] --force

ng 更新@angular/[电子邮件受保护] --force

ng 更新@angular/[电子邮件受保护] --force

确保使用正确的节点版本,如您正在使用的角度更新文档中所述。

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