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'
@types/webpack-env was since updated:
Conflict on module
was solved in this PR
process
was added in this commit
The code in the original question now only needs @types/webpack-env.
But importing @types/node alongside won't conflict anymore.
npm install --save-dev @types/webpack-env
And if you also need NodeJS environment definitions:
npm install --save-dev @types/node