看了这个链接https://stackoverflow.com/questions/49001115/npm-run-build-error-for-html-webpack-plugin
发现是正在使用Webpack和HtmlWebpackPlugin的不兼容,我使用的是webpack是4.43.0版本。
Webpack 4进行了一些过时的更改,并且html-webpack-plugin的作者未更改新要求的代码,因此,此插件不适用于新的webpack 4版本。
可以通过简单地从npm安装
npm i -D html-webpack-plugin@webpack-contrib/html-webpack-plugin