我将我的 webpack v4 升级到 v5,之后我收到“无法添加属性”错误

问题描述

我按照此文档 https://webpack.js.org/migrate/5 将我的 webpack v4 升级到 v5,之后我收到此错误

TypeError: Cannot add property htmlWebpackPluginAlterChunks,object is not extensible
    at /home/ec2-user/abhisar/insights-master/frontend/node_modules/html-webpack-plugin/index.js:59:56
    at Hook.eval [as call] (eval at create (/home/ec2-user/abhisar/insights-master/frontend/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10),<anonymous>:100:1)
    at Hook.CALL_DELEGATE [as _call] (/home/ec2-user/abhisar/insights-master/frontend/node_modules/webpack/node_modules/tapable/lib/Hook.js:14:14)
    at Compiler.newCompilation (/home/ec2-user/abhisar/insights-master/frontend/node_modules/webpack/lib/Compil

我该怎么做才能解决这个问题?

Error I get is related to html-webpack-plugin

解决方法

我知道这个答案有点晚了,但我最近遇到了同样的问题。我能够通过将我的 html-webpack-plugin 版本更新到 v5.3.2(截至撰写本文时的最新版本)来解决它。我正在使用 Node/NPM,因此对于我的解决方案,我只是更改了 package.json 文件中的版本号,然后运行 ​​npm install