首页 > 解决方案 > ERESOLVE 无法解析依赖树?

问题描述

当您尝试通过 Angular cli 创建 Angular 项目时,您会收到此错误

    npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: animation@0.0.0
npm ERR! Found: jasmine-core@3.6.0
npm ERR! node_modules/jasmine-core
npm ERR!   dev jasmine-core@"~3.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core@">=3.7.1" from karma-jasmine-html-reporter@1.6.0
npm ERR! node_modules/karma-jasmine-html-reporter
npm ERR!   dev karma-jasmine-html-reporter@"^1.5.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.

请帮帮我,我不明白这里需要做什么

标签: angularnpm

解决方案


更新(Angular 12.0.0)

在我回答后几个小时,Angular 12 就发布了——它与 NPM 完美配合7.13.0

原始答案(Angular 11.2.11)

您使用的是哪个 NPM 版本?

我刚刚使用 version 遇到了同样的问题7.10.0。降级到 后6.14.13ng new按预期工作。

npm i -g npm@6.14.13

目前,如果你想创建一个 Angular 项目,这似乎是最好的解决方案。但是, GitHub 上的相应问题已经关闭。所以我希望下一个 Angular 版本也可以与最新的 NPM 版本一起使用。

我希望我能帮助你。


推荐阅读