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、需要用{}

 

相关文章:

  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2022-01-04
  • 2021-08-22
  • 2022-12-23
猜你喜欢
  • 2021-05-24
  • 2021-11-23
  • 2021-09-04
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案