我創建了一個新的 create-react-app 模板并使用 npm run build 命令構建了專案并得到了這個錯誤。我彈出了 react-scripts 并尋找它沒有構建的原因,但我沒有找到任何東西。我已經修復了組件中的 css 檔案匯入。節點版本 16.13.2,npm 版本 8.1.2
/home/pawel/projekty/hashcode/config/webpack.config.js:623
new MiniCssExtractPlugin({
^
TypeError: MiniCssExtractPlugin is not a constructor
at module.exports (/home/pawel/projekty/hashcode/config/webpack.config.js:623:9)
at Object.<anonymous> (/home/pawel/projekty/hashcode/scripts/build.js:51:16)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
這是彈出的 webpack 配置https://github.com/PSmigielski/hashcode/blob/master/config/webpack.config.js
uj5u.com熱心網友回復:
這似乎是最近出現的一個新問題,并且已使用 create-react-app 存盤庫打開了一個問題。
https://github.com/facebook/create-react-app/issues/11930
現在的兩種解決方法似乎是這些
1.) 固定迷你 css 提取版本:
npm i -D --save-exact mini-css-extract-plugin@2.4.5
2.) 向 package.json 添加解析度也可以:
"resolutions": {
"mini-css-extract-plugin": "2.4.5"
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/416550.html
標籤:
