前端打包報錯:TypeError: Class extends value undefined is not a constructor or nul


報錯TypeError: Class extends value undefined is not a constructor or nul

在執行npm run build的時候遇到了錯誤:TypeError: Class extends value undefined is not a constructor or null;而執行npm run serve是可以正常執行的,報錯如下:

Building for production...
ERROR  TypeError: Class extends value undefined is not a constructor or null
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (E:\etest\lsj_test\node_modules\mini-css-extract-plugin\dist\CssDependency.js:12:46)...

根據報錯可得是mini-css-extract-plugin這個插件有問題,於是去這個插件npm官網看了一下,解決方法有兩種:

第一種是安裝這個插件:

npm install --save-dev mini-css-extract-plugin //在項目開發依賴中安裝
 

第二種是升級webpack版本(如果無效可以先卸載,再安裝):

 
npm install webpack -g // 全局安裝
npm install webpack --save-dev //在項目開發依賴中安裝


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM