TypeError: CleanWebpackPlugin is not a constructor

webpack添加Cleanweb packPlugin插件,按着webpack的指南来编写会报错

TypeError: CleanWebpackPlugin is not a constructor

//webpack指南的写法 抛错 
const CleanWebpackPlugin = require('clean-webpack-plugin');

......
    plugins: [
     new CleanWebpackPlugin(['dist']),
  ],

....

//正确写法
 
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

...

plugins: [
    new CleanWebpackPlugin()
]

...

 

以上解决方法参考了下面博主的博客

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/qq_36242361/article/details/90709258

 

posted @ 2019-09-11 15:25  KIU的博客  阅读(184)  评论(0编辑  收藏  举报