【问题标题】:facing problem when try to use npm run build尝试使用 npm run build 时遇到问题
【发布时间】:2022-01-15 19:28:17
【问题描述】:

当我尝试使用 npm run build 构建我的 react 项目时,显示错误。另外,尝试使用纱线构建。但出现了类似的错误。下面是我的代码,

TypeError: MiniCssExtractPlugin is not a constructor
at module.exports (A:\projects\Own Projects\project-listing-site\node_modules\react-scripts\config\webpack.config.js:664:9)
at Object.<anonymous> (A:\projects\Own Projects\project-listing-site\node_modules\react-scripts\scripts\build.js:58:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47

npm 错误!代码生命周期 npm 错误!错误号 1 npm 错误!项目列表站点@0.1.0 构建:react-scripts build npm 错误!退出状态 1 npm 错误! npm 错误!在 project-listing-site@0.1.0 构建脚本中失败。 npm 错误!这可能不是 npm 的问题。上面可能还有额外的日志输出。

npm 错误!可以在以下位置找到此运行的完整日志: npm 错误! C:\Users\user\AppData\Roaming\npm-cache_logs\2022-01-15T11_10_02_360Z-debug.log

【问题讨论】:

    标签: node.js npm


    【解决方案1】:

    尝试更改 mini-css-extract-plugin 版本。 如果您使用的是 yarn,请在 package.json 中更改为这个,然后运行 ​​yarn install:

      "resolutions": {
        "mini-css-extract-plugin": "2.4.5"
      },
    

    或者,如果您使用的是 npm,请运行:

    npm i -D --save-exact mini-css-extract-plugin@2.4.5
    

    如果这些都不起作用,请查看this github issue上的其他答案

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-03
      • 1970-01-01
      • 1970-01-01
      • 2022-08-06
      相关资源
      最近更新 更多