自学前端小白 2023-04-02 02:53 采纳率: 66.7%
浏览 33
已结题

TypeError: Class constructor HtmlWebpackPlugin cannot be invoked without 'new'

const path = require('path')
// 1.导入插件,得到构造函数
const HtmlPlugin = require('html-webpack-plugin')
// 2.创建插件的实例对象
const htmlPlugin = new HtmlPlugin({
    template: './src/index.html',
    filename: './index.html'
})
module.exports = {
    mode: 'development', // development  production
    // 指定打包的入口
    entry: path.join(__dirname, './src/index.js'),
    // 指定打包的出口
    output: {
        // 表示输出文件的存放路径
        path: path.join(__dirname, './dist'),
        // 表示输出文件的名称
        filename: 'bundle.js',
    },
    plugins: [HtmlPlugin]  //3.挂载插件的实例对象
}

img

各位,帮帮忙,看看怎么处理?

  • 写回答

1条回答 默认 最新

  • 社区专家-Monster-XH 2023-04-02 09:15
    关注

    挂载插件的实例对象的H改成h:

    plugins: [htmlPlugin]
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月11日
  • 已采纳回答 4月3日
  • 创建了问题 4月2日