如何解决我正在安装 Angular12,但遇到以下错误,请问我该怎么办和window版本有关系吗?
- Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: youtube@0.0.0
npm ERR! Found: @angular/compiler-cli@12.2.0-next.1
npm ERR! node_modules/@angular/compiler-cli
npm ERR! dev @angular/compiler-cli@"~12.2.0-next.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler-cli@"^12.0.0 || ^12.1.0-next" from @angular-devkit/build-angular@12.2.0-next.0
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~12.2.0-next.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\Politics17\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\Politics17\AppData\Local\npm-cache\_logs\2021-07-02T05_47_00_003Z-debug.log
× Package install failed,see above.
The Schematic workflow failed. See above.
解决方法
我在将节点版本更新到 12 时遇到了这个问题。运行了解决方案:
npm i --legacy-peer-deps
如果不想每次都运行npm i --legacy-peer-deps
,可以在npm配置文件中添加legacy-peer-deps=true
(项目根目录下的.npmrc,如果不存在可以创建) ).
关于legacy-peer-deps的信息
,使用这个命令:
npm install --save --legacy-peer-deps
这也可以设置为更永久的配置选项,如下所示:
npm config set legacy-peer-deps true
但是,如果上述方法不起作用,请尝试删除 node_modules
文件夹和 package-lock.json
文件,然后运行以下命令:
npm install
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。