前端打包报错: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 //在项目开发依赖中安装
posted @ 2022-03-21 17:29  背着泰山找黄河  阅读(5518)  评论(0编辑  收藏  举报