Html-webpack-plugin: this.htmlWebpackPlugin.getHooks is not a function

Created on 3 Oct 2018  Â·  20Comments  Â·  Source: jantimon/html-webpack-plugin

Getting this error on Linux system, but it's working fine on windows system.

Most helpful comment

i just updated my create-react-app application from webpack 3 to 4 and got the this.htmlWebpackPlugin.getHooks is not a function error. it took a combination of suggestions in this tread to resolve it.

  1. delete old node_modules and reinstall fresh
  2. as per @jantimon, npm i html-webpack-plugin@next
  3. as per @philihp, new InterpolateHtmlPlugin(env.raw), to new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),

All 20 comments

Sorry the issue quality is very low.
Please prepare the issue so it can be solved.

@fabioelia could you please tell me more about that?

getHooks is new in html-webpack-plugin 4.0.0.alpha-2

Older versions don't provide the static function.

Having the same issue after installing alpha-2 and trying to build my app with webpack4 (and the config provided in react-create-app).

What information do you need to investigate @jantimon ?

Running on: Windows, node 8.12.0

Maybe you have multiple html-webpack-plugin versions installed?

Indeed, sorry for the false bug.
After a yarn list, it seems that I was using two html-webpack-plugin versions.

Everything's ok for me :)

I am running on OSX 10.11, and I keep all software updated. I tried running npm audit fix --force on https://github.com/tongeren/react16 (actually chapter 8.1) and I am getting this error.
Upgrading to "html-webpack-plugin": "^4.0.0-beta.2" does not help. I ensured removing any relevant duplicate libraries.

To add another data point here, I encountered this when upgrading react-dev-utils from
6.0.0-next.3e165448 to 6.1.1.

What resolved it was @kylealwyn's suggestion https://github.com/facebook/create-react-app/issues/5465#issuecomment-430780219, where in my build.js I had to change

new InterpolateHtmlPlugin(env.raw),

to

new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),

I'm getting this issue from html-webpack-harddisk-plugin.

https://github.com/jantimon/html-webpack-harddisk-plugin/blob/master/index.js#L22-L24

EDIT: seems like some other error in my process caused this one.

@philihp
changing to new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw), didnt work for me

I'm updated a html-webpack-plugin from 3.2.0 to 4.0.0-alpha.2, but some problem happened yet.
Questions as follows:
yarn run v1.12.3
$ node scripts/start.js
this.htmlWebpackPlugin.getHooks is not a function
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

4.0.0.alpha-2 of html-webpack-plugin is not listed on the releases page

@snoblenet what is https://www.npmjs.com/package/html-webpack-plugin/v/4.0.0-alpha.2 ?
That might have been the latest, 2 months ago.
I've updated npm, and re-installed https://github.com/tongeren/react16 chapter 8.1
I still get high priority vulnerabilities that npm audit fix --force cannot resolve, but I am now not seeing html-webpack-plugin directly. May need further hacking.

All published versions can be found here: https://www.npmjs.com/package/html-webpack-plugin?activeTab=versions

Please use npm i html-webpack-plugin@next

when I update html-webpack-plugin for @4.0.0-beta.5 but there is another error. Cannot find module 'import-local' but I never import this module??

Just wanted to chime in on this issue. I have a react app created usingcreate-react-app. I got a warning from npm audit so I upgraded my packages to the latest and encountered this issue.

I executed npm i html-webpack-plugin@next as specified by @jantimon and it's at version 4.0.0-beta5, but I'm still getting the same error message when I run npm start on my project.

I remove all the directory of node_modules . npm install again it is ok for me

Strange... I tried this again just now by removing node_modules after running npm i html-webpack-plugin@next and I'm still having issues. I'm not sure why it isn't working for me.

> [email protected] start /Users/awang/dev/service-animal
> node scripts/start.js

this.htmlWebpackPlugin.getHooks is not a function
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/awang/.npm/_logs/2019-01-01T18_08_17_639Z-debug.log

i just updated my create-react-app application from webpack 3 to 4 and got the this.htmlWebpackPlugin.getHooks is not a function error. it took a combination of suggestions in this tread to resolve it.

  1. delete old node_modules and reinstall fresh
  2. as per @jantimon, npm i html-webpack-plugin@next
  3. as per @philihp, new InterpolateHtmlPlugin(env.raw), to new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),

@adambreznicky Thanks! It's working your solution.

Was this page helpful?
0 / 5 - 0 ratings