npm ERR! code ERESOLVE

vue安装命令, npm install时报错:


D:\workspace\IM\websocket-master>npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: react-demo@1.0.0
npm ERR! Found: webpack@3.12.0
npm ERR! node_modules/webpack
npm ERR! dev webpack@"^3.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^2.2.0" from extract-text-webpack-plugin@2.1.2
npm ERR! node_modules/extract-text-webpack-plugin
npm ERR! dev extract-text-webpack-plugin@"^2.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 D:\tools\node-v10.7.0-win-x64\node_cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! D:\tools\node-v10.7.0-win-x64\node_cache\_logs\2022-06-29T01_21_50_418Z-debug-0.log

输入npm -V发现我的npm版本为7.x的,因为npm7.x版本对某些命令比npm6.x更严格,所以莫名报了这个错

解决办法有两种:
1.在命令后加上--legacy-peer-deps
2.使用npm6.x

提示:使用npm@6不需要卸载npm@7。可以使用npx指定npm的版本。例如:npx -p npm@6 npm i --legacy-peer-deps

如果这不能立即起作用,可以先删除 node_modules和 package-lock.json
npm install -D sass-loader node-sass --legacy-peer-deps

安装成功

1、所有文章未经授权禁止转载、摘编、复制或建立镜像,如有违反,追究法律责任。
2、本站文章部分来源注册用户发布或互联网收集而来,若有侵权,请邮件联系作者。
邮箱地址:wtao219@qq.com
THE END
分享
二维码
< <上一篇
下一篇>>