webpack打包问题记录

问题:

 npm run dev

> webpack-first@1.0.0 dev /Users/xiexin/project/webpack-first
> npx webpack --mode=development

/Users/xiexin/project/webpack-first/node_modules/.pnpm/registry.npmmirror.com+webpack-cli@3.3.10_webpack@4.41.5/node_modules/webpack-cli/bin/cli.js:281
                                throw err;
                                ^

TypeError: Cannot read property 'tap' of undefined
    at HtmlWebpackPlugin.apply (/Users/xiexin/project/webpack-first/node_modules/.pnpm/registry.npmmirror.com+html-webpack-plugin@5.5.0_webpack@4.41.5/node_modules/html-webpack-plugin/index.js:40:31)
    at webpack (/Users/xiexin/project/webpack-first/node_modules/.pnpm/registry.npmmirror.com+webpack@4.41.5_webpack-cli@3.3.10/node_modules/webpack/lib/webpack.js:51:13)
    at processOptions (/Users/xiexin/project/webpack-first/node_modules/.pnpm/registry.npmmirror.com+webpack-cli@3.3.10_webpack@4.41.5/node_modules/webpack-cli/bin/cli.js:272:16)
    at /Users/xiexin/project/webpack-first/node_modules/.pnpm/registry.npmmirror.com+webpack-cli@3.3.10_webpack@4.41.5/node_modules/webpack-cli/bin/cli.js:364:3
    at Object.parse (/Users/xiexin/project/webpack-first/node_modules/.pnpm/registry.npmmirror.com+yargs@13.2.4/node_modules/yargs/yargs.js:567:18)
    at /Users/xiexin/project/webpack-first/node_modules/.pnpm/registry.npmmirror.com+webpack-cli@3.3.10_webpack@4.41.5/node_modules/webpack-cli/bin/cli.js:49:8
    at Object.<anonymous> (/Users/xiexin/project/webpack-first/node_modules/.pnpm/registry.npmmirror.com+webpack-cli@3.3.10_webpack@4.41.5/node_modules/webpack-cli/bin/cli.js:366:3)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/Users/xiexin/project/webpack-first/node_modules/.pnpm/registry.npmmirror.com+webpack@4.41.5_webpack-cli@3.3.10/node_modules/webpack/bin/webpack.js:156:2)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
    at internal/main/run_main_module.js:17:47
 ELIFECYCLE  Command failed with exit code 1.

原因:html-webpack-plugin版本过高,使用的是^5.0.0
解决方案:删除插件重装,重装时指定插件版本,降为4.0.0后解决。

npm install html-webpack-plugin@4.0.0 -D
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值