前端打包报错: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