我刚刚使用 Angular 17 初始化了一个新项目,但我不知道为什么出现错误:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @angular/[email protected]
npm ERR! node_modules/@angular/core
npm ERR! @angular/core@"^17.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"17.0.1" from @angular/[email protected]
npm ERR! node_modules/@angular/animations
npm ERR! @angular/animations@"^17.0.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!
@angular/core@"17.0.1" from @angular/[email protected]
:我知道没有17.0.1版本。但只有 17.0.0.
当我发布问题时,我找到了解决方案:
我安装了:
npm install @angular/[email protected]
和
npm install @angular/[email protected]
最后:
ng update
删除你的
package-lock.json
和你node_modules
,你就会没事的。