UnhandledPromiseRejectionWarning: TypeError: this.htmlWebpackPlugin.getHooks is not a function
See original GitHub issueIs this a bug report? (Yes)
Currently hitting an issue with our environment using webpack 4 and the latest 6.0.5 package from create-react-app. Currently in the process we utilize react-dev-utils/InterpolateHtmlPlugin
which has a method getHooks
which seems to be leading to the following error:
(node:25316) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
(node:25316) UnhandledPromiseRejectionWarning: TypeError: this.htmlWebpackPlugin.getHooks is not a function
From what I can tell a commit 28 days ago may have re-introduced this old syntax, as https://github.com/facebook/create-react-app/blame/d55525651fb57e6ca6fb79c1d5c61601c129cbbd/packages/react-dev-utils/InterpolateHtmlPlugin.js this prior version seemed to use the new hook api
I’m not familiar enough with the codebase to suggest a fix, if just that file may have regressed or others.
Did you try recovering your dependencies?
Which terms did you search for in User Guide?
Environment
Steps to Reproduce
Coming Soon
Expected Behavior
Actual Behavior
Reproducible Demo
Coming Soon
Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Top Results From Across the Web
Webpack 4, this.htmlWebpackPlugin.getHooks is not a function
I'm migrating from webpack 3 to 4 and it is painfull ;). I'm getting this error: this.htmlWebpackPlugin.getHooks is not a function. I was...
Read more >this.htmlWebpackPlugin.getHooks is not a function · Issue #1068
Having the same issue after installing alpha-2 and trying to build my app with webpack4 (and the config provided in react-create-app).
Read more >How to use the html-webpack-plugin.getHooks function ... - Snyk
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >html-webpack-plugin - npm
This is a webpack plugin that simplifies creation of HTML files to serve your webpack bundles. This is especially useful for webpack bundles ......
Read more >解决webpack打包错误:this.htmlWebpackPlugin.getHooks is ...
this.htmlWebpackPlugin.getHooks is not a function 报错描述 经过一番搜索,在html-webpack-plugin的issue区看到了如下解决方法,亲测可用。
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same issue. In case there’s someone else trying to upgrade to webpack 4 on a a react app, here’s some tips I had to do to make it working:
run
npm install <plugin-name>@latest --save
with all webpack plugins that you have runnpm i html-webpack-plugin@next --save
to get the beta version of html-webpack-plugin (this works with webpack 4) Upgradereact-dev-utils
andreact
if necessary Make surenew InterpolateHtmlPlugin(...
is AFTER newHtmlWebpackPlugin({...
in the plugins section of webpack.config file. Add theHtmlWebpackPlugin
as parameter toInterpolateHtmlPlugin
as stated by @kylealwyn and don’t forget the publicUrl in case you’re using it:(Extra) Also since I’m using typescript, I had to update
@types/webpack
.I hope this helps someone else 😃
https://github.com/facebook/create-react-app/pull/5031/files#diff-ea4f448ea185319313285123e7f97294R48
It looks like you now need to pass the
HtmlWebpackPlugin
object when adding theInterpolateHtmlPlugin
This fixed the issue for me.