【问题标题】:How to run Angular 12 project using Angular CLI 13如何使用 Angular CLI 13 运行 Angular 12 项目
【发布时间】:2022-01-04 02:52:55
【问题描述】:

我下载了一个 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 安装,但也抛出了一些其他错误:

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:

有什么帮助吗?

【问题讨论】:

  • 由于某些原因,您的某些库的版本不兼容,请尝试将 rxjs 降级到 6.6.7
  • 请分享您的package.json

标签: node.js angular npm angular12 angular13


【解决方案1】:

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

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

然后运行npm install

希望这可行

【讨论】:

  • 我试过了,但它也返回了这个错误:Package '@angular/core' is not a dependency.
  • 这是因为缺少node_modules 文件夹,因为运行npm install 会引发错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-15
  • 1970-01-01
  • 2018-03-18
  • 2018-07-08
  • 1970-01-01
  • 2021-12-22
相关资源
最近更新 更多