小编Moh*_*lam的帖子

运行命令“npm run build”时出现错误,错误“TypeError:MiniCssExtractPlugin不是构造函数”

我正在使用 React 创建一个应用程序,它运行良好npm start,但是当我尝试构建该应用程序时,显示以下错误。

PS D:\ ****\ **\*\profile> npm run build

> profile@0.1.0 build
> react-scripts build

D:\ ****\ **\profile\node_modules\react-scripts\config\webpack.config.js:664
        new MiniCssExtractPlugin({
        ^

TypeError: MiniCssExtractPlugin is not a constructor
    at module.exports (D:\Documents\Project\React\profile\node_modules\react-scripts\config\webpack.config.js:664:9)
    at Object.<anonymous> (D:\Documents\Project\React\profile\node_modules\react-scripts\scripts\build.js:58:16)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Run Code Online (Sandbox Code Playgroud)

我在用着

包裹名字 版本
节点 16.13.2
新项目管理 8.1.2
恩克斯 8.1.2

这是我的package.json文件。

{
  "name": "profile",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": …
Run Code Online (Sandbox Code Playgroud)

node.js npm reactjs create-react-app mini-css-extract-plugin

11
推荐指数
1
解决办法
5376
查看次数