1 // webpack版本:4.32.2 2 3 // 抛错原写法 4 const CleanWebpackPlugin = require("clean-webpack-plugin"); 5 6 ... 7 8 plugins: [ 9 new CleanWebpackPlugin(['dist']) 10 ] 11 12 ... 13 14 // 另一种错误写法 15 16 const CleanWebpackPlugin = require("clean-webpack-plugin"); 17 18 ... 19 20 plugins: [ 21 new CleanWebpackPlugin(['dist'], { 22 root: path.resolve(__dirname, '../'), //根目录 23 }) 24 ] 25 26 ... 27 28 // =============================分割线============================== 29 30 // 正确写法 31 32 const { CleanWebpackPlugin } = require("clean-webpack-plugin"); 33 34 ... 35 36 plugins: [ 37 new CleanWebpackPlugin() 38 ] 39 40 ...