webpack清理插件错误——TypeError: CleanWebpackPlugin is not a constructor

Error: clean-webpack-plugin only accepts an options object.

TypeError: CleanWebpackPlugin is not a constructor

以上两个错误属于同一个

之前这样写的:

const CleanWebpackPlugin = require("clean-webpack-plugin");

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

然后报错:TypeError: CleanWebpackPlugin is not a constructor

后来这样写:

const {CleanWebpackPlugin} = require("clean-webpack-plugin");

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

继续报错:Error: clean-webpack-plugin only accepts an options object.

最后这样写:

const {CleanWebpackPlugin} = require("clean-webpack-plugin");

plugins:[
 new CleanWebpackPlugin(),   
]

 成功运行~

 

两点:

1、new CleanWebpackPlugin()中不能写参数,
2、需要用{}

 

posted @ 2019-09-18 11:31  足迹#  阅读(991)  评论(0编辑  收藏  举报