如何降级 Angular 项目

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

我需要将我的 Angular 项目从 16.2.x 降级到 16.1.x。 我安装了 Angular Globaly,这是 ng 版本的输出:

 cli: 16.1.8
 node: 18.10.0. 

我已经尝试删除节点模块文件夹并使用 npm install @angular/[email protected]。但是,我收到这些错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/zone.js
npm ERR!   zone.js@"~0.14.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer zone.js@"~0.13.0" from @angular/[email protected]
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"^16.1.0" from the root project
npm ERR!   peer @angular/core@"16.2.12" from @angular/[email protected]
npm ERR!   node_modules/@angular/animations
npm ERR!     @angular/animations@"^16.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! See C:\Users\matmi\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\matmi\AppData\Local\npm-cache\_logs\2023-12-13T22_45_06_528Z-debug-0.log
node.js angular angular-cli downgrade dependency-tree
1个回答
0
投票

编辑 package.json 文件,如以下代码所示。

    "@angular/animations": "^16.1.0",
    "@angular/cdk": "^16.1.0",
    "@angular/common": "^16.1.0",
    "@angular/compiler": "^16.1.0",
    "@angular/core": "^16.1.0",
    "@angular/forms": "^16.1.0",
    "@angular/platform-browser": "^16.1.0",
    "@angular/platform-browser-dynamic": "^16.1.0",
    "@angular/router": "^16.1.0",

然后删除node_module并重新安装

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