npm 无法解析css加载程序的依赖关系对等Webpack5

lf5gs5x2  于 2022-11-14  发布在  Webpack
关注(0)|答案(1)|浏览(217)

实际上,我是一个很新的javascript,我想安装vue-audio-visual到我的项目。但我得到了奇怪的错误在我的节点控制台,我不知道是什么关系。npm错误如下所示:

code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: css-loader@6.6.0
npm ERR! Found: webpack@4.46.0
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.7.1" from @vue/cli-service@4.5.15
npm ERR!     node_modules/@vue/cli-service
npm ERR!       peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-babel@4.5.15
npm ERR!       node_modules/@vue/cli-plugin-babel
npm ERR!         dev @vue/cli-plugin-babel@"~4.5.0" from the root project
npm ERR!       3 more (@vue/cli-plugin-router, @vue/cli-plugin-vuex, the root project)
npm ERR!   webpack@"^4.0.0" from @vue/cli-plugin-babel@4.5.15
npm ERR!   node_modules/@vue/cli-plugin-babel
npm ERR!     dev @vue/cli-plugin-babel@"~4.5.0" from the root project
npm ERR!   19 more (cache-loader, thread-loader, @vue/cli-service, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^5.0.0" from css-loader@6.6.0
npm ERR! node_modules/css-loader
npm ERR!   peer css-loader@"*" from vue-loader@15.10.0
npm ERR!   node_modules/vue-loader
npm ERR!     vue-loader@"^15.9.2" from @vue/cli-service@4.5.15
npm ERR!     node_modules/@vue/cli-service
npm ERR!       peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-babel@4.5.15
npm ERR!       node_modules/@vue/cli-plugin-babel
npm ERR!       3 more (@vue/cli-plugin-router, @vue/cli-plugin-vuex, the root project)
npm ERR!   css-loader@"^6.6.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: webpack@5.74.0
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^5.0.0" from css-loader@6.6.0
npm ERR!   node_modules/css-loader
npm ERR!     peer css-loader@"*" from vue-loader@15.10.0
npm ERR!     node_modules/vue-loader
npm ERR!       vue-loader@"^15.9.2" from @vue/cli-service@4.5.15
npm ERR!       node_modules/@vue/cli-service
npm ERR!         peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-babel@4.5.15
npm ERR!         node_modules/@vue/cli-plugin-babel
npm ERR!         3 more (@vue/cli-plugin-router, @vue/cli-plugin-vuex, the root project)
npm ERR!     css-loader@"^6.6.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 /Users/julapps/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/julapps/.npm/_logs/2022-10-23T12_42_49_511Z-debug-0.log

但是,在我的package.json文件中,我使用这些依赖项css-loader": "^6.6.0"
和VUE DEP:

"devDependencies": {
  "@vue/cli-plugin-babel": "~4.5.0",
  "@vue/cli-plugin-router": "^4.5.15",
  "@vue/cli-service": "~4.5.0",
  "@vue/compiler-sfc": "^3.0.0",
  "webpack": "^4.46.0"
}

谁能给我解释一下我该怎么办?

0s7z1bwu

0s7z1bwu1#

你用的是带Webpack的Vue 3而不是Vite?
不确定这是否是一个已知的选择,但我宁愿推荐维特。
至于为什么会出现这个问题,错误解释得很好。让我翻译一下:
要安装css-loader(或任何依赖于它的东西),我至少需要Webpack 5
如果您检查给定包的the changelog,您可以看到Webpack 5确实是一个强制升级
支持的最低Webpack版本为5,建议更新到最新版本以获得更好的性能
您可以:

  • 宁可使用Vite
  • 使用npm安装Webpack 5
  • 使用Yarn/pnpm,以获得更好的误差

相关问题