-1

我下载了一个 Angular 12 项目,并尝试使用 Angular 13(最新版本)运行它。因此,当我尝试运行它时会遇到问题。即使我尝试使用 npm install,也会抛出一些依赖问题

使用运行时抛出的错误ng serve

An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
- /usr/local/lib/node_modules/@angular/cli/models/architect-command.js
- /usr/local/lib/node_modules/@angular/cli/commands/serve-impl.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /usr/local/lib/node_modules/@angular/cli/utilities/json-schema.js
- /usr/local/lib/node_modules/@angular/cli/models/command-runner.js
- /usr/local/lib/node_modules/@angular/cli/lib/cli/index.js
- /usr/local/lib/node_modules/@angular/cli/lib/init.js
See "/private/var/folders/w0/wfq3__js19g4lbf33bpkwbrm0000gp/T/ng-hQcZ24/angular-errors.log" for further details.

我尝试使用 npm install,但也抛出了一些其他错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: black-dashboard-angular@1.2.0
npm ERR! Found: rxjs@7.2.0
npm ERR! node_modules/rxjs
npm ERR!   rxjs@"7.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer rxjs@"^6.5.3" from @angular/core@12.1.2
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"12.1.2" from the root project
npm ERR!   peer @angular/core@"12.1.2" from @angular/animations@12.1.2
npm ERR!   node_modules/@angular/animations
npm ERR!     @angular/animations@"12.1.2" 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 /Users/aless/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:

请问有什么帮助吗?

4

1 回答 1

0

尝试通过运行将项目的角度版本从 v12 更新到 v13:

npx @angular/cli@13 update @angular/core@13 @angular/cli@13

然后运行npm install

希望这有效

于 2021-11-25T22:13:28.730 回答