npm ERR: code ERESOLVE 处理方法
今天在安装sass的时候报错:PS E:\VUEJS 2.6\test2\xmall> npm install -D sass-loader node-sassnpm ERR! code ERESOLVEnpm ERR! ERESOLVE could not resolvenpm ERR!npm ERR! While resolving: element-ui@2.15.6npm ERR!
·
今天在安装sass的时候报错:
PS E:\VUEJS 2.6\test2\xmall> npm install -D sass-loader node-sass
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: element-ui@2.15.6
npm ERR! Found: vue@3.2.31
npm ERR! node_modules/vue
npm ERR! peerOptional vue@"^2 || ^3.2.13" from @vue/babel-preset-app@5.0.4
npm ERR! @vue/babel-preset-app@"^5.0.4" from @vue/cli-plugin-babel@5.0.4
npm ERR! node_modules/@vue/cli-plugin-babel
npm ERR! dev @vue/cli-plugin-babel@"~5.0.0" from the root project
npm ERR! peer vue@"3.2.31" from @vue/server-renderer@3.2.31
npm ERR! node_modules/@vue/server-renderer
npm ERR! @vue/server-renderer@"3.2.31" from vue@3.2.31
npm ERR! 3 more (vue-router, vuex, the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^2.5.17" from element-ui@2.15.6
npm ERR! node_modules/element-ui
npm ERR! element-ui@"^2.4.5" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: vue@2.6.14
npm ERR! node_modules/vue
npm ERR! peer vue@"^2.5.17" from element-ui@2.15.6
npm ERR! node_modules/element-ui
npm ERR! element-ui@"^2.4.5" 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\HTADMIN\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\HTADMIN\AppData\Local\npm-cache\_logs\2022-04-04T01_26_53_375Z-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
PS E:\VUEJS 2.6\test2\xmall> npm install -D sass-loader node-sass --legacy-peer-deps
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
added 145 packages, and audited 1025 packages in 14s
6 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
PS E:\VUEJS 2.6\test2\xmall>
安装成功了!
更多推荐
已为社区贡献3条内容
所有评论(0)