Also ts+react 'hot' does not exist on type' NodeModule'

also ts+react webpack is configured with HotModuleReplacementPlugin ()\,
Why do I module.hot error: TS2339: Property "hot" does not exist on type" NodeModule".

webpack.config.js

    new webpack.HotModuleReplacementPlugin(),

demo.ts

    if(module.hot) {
    {
        // ...
    }

TS2339: Property "hot" does not exist on type" NodeModule".

clipboard.png

resolved

solution:

1. if (module as any).hot {}

2. yarn add @types/webpack.env -D
If

is normal, you can ignore


by configuring the types file or writing the condition directly.

without looking at the detailed code, you can't see what's wrong. The easiest way is to use webpack-dev-server instead.

and take a look at your error prompt error, there is a code error in your source file. Your picture is incomplete. There should be a message on the right.

Menu