HtmlWebpackPlugin打包报错

来源:3-5 使用 plugins 让打包更便捷

水荷

2021-03-25

不用这个插件是可以打包的,用了就报错。

webpack.config.js代码如下:

var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    mode: "development",
    entry: "./index.js",
    plugins: [new HtmlWebpackPlugin()],
    output:{
        filename: "index.js"
    }
}

package.json代码如下:

{
  "name": "test-webpack",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "bundle": "webpack"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "html-webpack-plugin": "^5.3.1",
    "webpack-cli": "^3.3.12"
  },
  "dependencies": {
    "webpack": "^4.46.0"
  },
  "description": ""
}

/Users/shiminghui/Desktop/my/code/testWebpack/node_modules/webpack-cli/bin/cli.js:281
throw err;
TypeError: Cannot read property ‘tap’ of undefined

写回答

1回答

Dell

2021-03-26

重新安装一次依赖

0
2
Dell
回复
水荷
应该是之前依赖没有安装全
2021-03-27
共2条回复

从基础到实战 手把手带你掌握新版Webpack4.0

知识点+项目实例+原理讲解 全方位解析Webpack4新版本

3627 学习 · 1291 问题

查看课程