Webpack TypeScript module.hot does not exist

kube picture kube · Nov 12, 2016 · Viewed 16.5k times · Source

I want to enable Webpack HMR in a NodeJS project written in TypeScript.

But module.hot is not available:

  • @types/webpack-env defines:

    declare var module: __WebpackModuleApi.Module
    
  • Which conflicts with @types/node definition:

    declare var module: NodeModule
    

Removing @types/node, solves the issue, but disables process:

process.env.NODE_ENV === 'production' // [ts] Cannot find name 'process'

Answer

WooCaSh picture WooCaSh · Aug 17, 2017

As few guys wrote here it's the best way:

npm i -D @types/webpack-env

For me it works as expected, resolving issue with not recognized hot property.

In my project I'm using those versions:

"@types/node": "^8.0.19",
"@types/webpack-env": "^1.13.0"

I don't know if question is still up to date but for my problem installing types for webpack help me.