前言
公司换了电脑,配置好前端环境后,运行项目项目报错,拿之前的依赖包用也不行。一开始想到的是版本问题,后来版本检查版本也是对的,搞了很久,快吐了,一起看一下错误吧。 如果这种解决办法不准确的话,还请大佬们指正。当然有更好的办法的话也可再评论区指点一二。在此抱拳了!
报错
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: sass-loader@7.3.1
npm ERR! Found: webpack@5.88.2
npm ERR! node_modules/webpack
npm ERR! peer webpack@"^4.0.0 || ^5.0.0" from @soda/friendly-errors-webpack-plugin@1.8.1
npm ERR! node_modules/@soda/friendly-errors-webpack-plugin
npm ERR! @soda/friendly-errors-webpack-plugin@"^1.8.0" from @vue/cli-service@5.0.8
npm ERR! node_modules/@vue/cli-service
npm ERR! dev @vue/cli-service@"~5.0.0" from the root project
npm ERR! 4 more (@vue/cli-plugin-babel, @vue/cli-plugin-eslint, ...)
npm ERR! webpack@"^5.54.0" from @vue/cli-plugin-babel@5.0.8
npm ERR! node_modules/@vue/cli-plugin-babel
npm ERR! dev @vue/cli-plugin-babel@"~5.0.0" from the root project
npm ERR! 18 more (@vue/cli-plugin-eslint, @vue/cli-service, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^3.0.0 || ^4.0.0" from sass-loader@7.3.1
npm ERR! node_modules/sass-loader
npm ERR! dev sass-loader@"^7.3.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: webpack@4.47.0
npm ERR! node_modules/webpack
npm ERR! peer webpack@"^3.0.0 || ^4.0.0" from sass-loader@7.3.1
npm ERR! node_modules/sass-loader
npm ERR! dev sass-loader@"^7.3.1" 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!
npm ERR! For a full report see:
npm ERR! C:\Users\Administrator\AppData\Local\npm-cache\_logs\2024-01-29T03_25_14_151Z-eresolve-report.txt
这个错误什么什么巴拉巴拉的。
问题解决
把package.json
里面的sass-loader和node-sass手动删掉,然后再终端npm install
,这样依赖包就可以下载下来了。最后重新下载一下sass-loader
和node-sass
就可以了
总结
- 所有问题都经不起推敲。
- 确实应该学一学程序员的英语
- 遇到问题,希望大家冷静处理,不要慌张乱了手脚。