TypeError: CleanWebpackPlugin is not a constructor

The introduction of clean-webpack-plugin package after an error in the project

new CleanWebpackPlugin(),
^

TypeError: CleanWebpackPlugin is not a constructor

Project writing:
Introducing: cnpm i clean-webpack-plugin -D
webpack.config.js中
const CleanWebpackPlugin = require('clean-webpack-plugin')

plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
        filename: 'index.html',
        template: './src/index.html'
    })
],        

Looked at the wording githup, clean-webpack-plugin is now introduced a new version has been changed const  CleanWebpackPlugin  the require ( 'clean-webpack-plugin ' ) ;

So modify the wording of the introduction to OK

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

plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
        filename: 'index.html',
        template: './src/index.html'
    })
],   

 

 

Guess you like

Origin www.cnblogs.com/steamed-twisted-roll/p/10990309.html