首页 > 解决方案 > 无法安装 $ npm i mini-css-extract-plugin。可能是什么问题呢?

问题描述

这是错误。我将 Visual Studio 代码与 gitBash 一起使用。

$ npm i mini-css-extract-plugin
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: lesson-54-intro-webpack@1.0.0
npm ERR! Found: webpack@4.46.0
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"^4.39.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^5.0.0" from mini-css-extract-plugin@2.2.0
npm ERR! node_modules/mini-css-extract-plugin
npm ERR!   mini-css-extract-plugin@"*" 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\Smith\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\Smith\AppData\Local\npm-cache\_logs\2021-08-19T13_12_04_740Z-debug.log

这是我的包 JSON 文件。这里有什么问题?如何匹配版本?

{ "name": "lesson-54-intro-webpack", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "dev" : "webpack-dev-server", "build": "webpack" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "@babel/core ": "^7.5.5", "@babel/preset-env": "^7.5.5", "autoprefixer": "^9.6.1", "babel-core": "^6.26.3", " babel-loader": "^8.0.6", "babel-polyfill": "^6.26.0", "css-loader": "^3.1.0", "file-loader": "^4.1.0" , "html-webpack-plugin": "^3.2.0", "postcss-loader”:“^3.0.0”,“precss”:“^4.0.0”,“style-loader”:“^0.23.1”,“webpack”:“^4.39.1”,“webpack- cli": "^3.3.6", "webpack-dev-server": "^3.7.2" }, "依赖项": { "axios": "^0.19.0" } }

标签: javascriptcssnode.jsnpmwebpack

解决方案


请参阅下面的编辑。

正如错误所说的 webpack 版本不匹配尝试:

  • 升级lesson-54-intro-webpack
  • 降级mini-css-extract-plugin

编辑:根据您的package.json内容

您需要将webpack版本升级到版本 5


推荐阅读