【问题标题】:Error when creating a new project using Angular CLI 13.1.0使用 Angular CLI 13.1.0 创建新项目时出错
【发布时间】:2022-01-15 03:55:49
【问题描述】:

使用 Angular CLI v13.1.0 创建新项目时出现以下错误

\ Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: example-app@0.0.0
npm ERR! Found: typescript@4.5.3
npm ERR! node_modules/typescript
npm ERR!   dev typescript@"~4.5.2" from the root project
npm ERR!   peer typescript@">=4.4.3 <4.6" from @angular-devkit/build-angular@13.1.0
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~13.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@">=4.4.2 <4.5" from @angular/compiler-cli@13.0.3
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   dev @angular/compiler-cli@"~13.0.0" from the root project
npm ERR!   peer @angular/compiler-cli@"^13.0.0 || ^13.1.0-next" from @angular-devkit/build-angular@13.1.0
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~13.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\user\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\user\AppData\Local\npm-cache\_logs\2021-12-10T12_46_21_814Z-debug.log
× Package install failed, see above.
The Schematic workflow failed. See above.

我使用的是Node JS版本16.13.1npm版本8.1.2

我尝试使用 --force 清除 npm 缓存,还重新安装了 Node JS。还是没有运气。

【问题讨论】:

    标签: angular typescript npm angular-cli npm-install


    【解决方案1】:

    所以我这样解决了:

    1. 我使用ng new 创建了项目。然后它创建了项目,但在安装依赖项时抛出了错误。

    2. 然后我手动编辑了package.json 文件并将所有角度包版本13.0.0 替换为13.1.0 并运行npm i

    之后,所有软件包都安装得很好,我可以运行ng serve

    【讨论】:

      【解决方案2】:

      这只是一个 TypeScript 补丁版本问题,正在这里跟踪:https://github.com/angular/angular-cli/issues/22333,所以只需降级或npm i --force,直到他们修复它。

      【讨论】:

        【解决方案3】:

        走这条路

        C:\Users\user\AppData\Local

        并删除此文件夹。

        npm 缓存

        然后测试它。

        【讨论】:

          猜你喜欢
          • 2017-01-25
          • 1970-01-01
          • 1970-01-01
          • 2019-01-12
          • 1970-01-01
          • 2018-05-25
          • 2020-01-16
          • 2019-03-06
          • 1970-01-01
          相关资源
          最近更新 更多