webpack打包之clean-webpack-plugin插件 默认下载4.0.0版本的踩坑记录
生活随笔
收集整理的这篇文章主要介绍了
webpack打包之clean-webpack-plugin插件 默认下载4.0.0版本的踩坑记录
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
关于使用clean-webpack-plugin插件打包报错问题,起初在网上寻找解决方案,有很多相关的文章博客都有谈到。
起初使用插件报错
TypeError: CleanWebpackPlugin is not a constructor解决方案一之插件引入方式错误
const CleanWebpackPlugin = require('clean-webpack-plugin'); // 1.0.0版本 2.0.0版本 const { CleanWebpackPlugin } = require('clean-webpack-plugin'); // 3.0.0版本解决方案二之插件使用方式错误
new CleanWebpackPlugin(), // 这样就可以了,里面不需要加什么路径了改完发现还是会报错
E:\vuework\my-project\node_modules\clean-webpack-plugin\dist\clean-webpack-plugin.js:83hooks.emit.tap('clean-webpack-plugin', compilation => {^ TypeError: Cannot read property 'emit' of undefined最后发现原来是使用4.0.0版本导致的
固定下载3.0.0版本(npm install --save-dev clean-webpack-plugin@3.0.0)到这里问题就解决了。
总结
以上是生活随笔为你收集整理的webpack打包之clean-webpack-plugin插件 默认下载4.0.0版本的踩坑记录的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 钉钉怎么退出原来的公司
- 下一篇: hexo部署到github时,提示typ