報錯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 //在項目開發依賴中安裝