Error: clean-webpack-plugin only accepts an options object.webpack
TypeError: CleanWebpackPlugin is not a constructorweb
以上兩個錯誤屬於同一個ui
以前這樣寫的:spa
const CleanWebpackPlugin = require("clean-webpack-plugin"); plugins:[ new CleanWebpackPlugin(['dist']), ]
而後報錯:TypeError: CleanWebpackPlugin is not a constructorcode
後來這樣寫:blog
const {CleanWebpackPlugin} = require("clean-webpack-plugin"); plugins:[ new CleanWebpackPlugin(['dist']), ]
繼續報錯:Error: clean-webpack-plugin only accepts an options object.io
最後這樣寫:class
const {CleanWebpackPlugin} = require("clean-webpack-plugin"); plugins:[ new CleanWebpackPlugin(), ]
成功運行~require
兩點:object
一、new CleanWebpackPlugin()中不能寫參數,二、須要用{}