zoukankan      html  css  js  c++  java
  • webpack清理插件错误——TypeError: CleanWebpackPlugin is not a constructor

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

     

  • 相关阅读:
    初步了解Ajax
    什么是applet
    FilterLog代码分析
    Async分析
    HttpServletRequest hrequest
    xml的定义用途
    企业级与应用级的区别
    未来规划
    黄金点游戏
    hashCode与eqauls
  • 原文地址:https://www.cnblogs.com/baby-zuji/p/11540718.html
Copyright © 2011-2022 走看看