Webpack 5.10.0 with @types/webpack-env 1.16.0 - HMR 错误"Property 'hot' does not exist on type 'Nod



根据Webpack 5文档,我不再安装@types/Webpack,尽管我尝试过安装它,看看它是否有任何不同,但没有。

我的应用程序条目:-

if (module.hot) {
module.hot.accept('./App', () => {
/* eslint-disable-next-line */
const NextApp = require('./App').default
renderApp(NextApp)
})
}

在我的开发部门中,我安装了types/webpack-env:-

"@types/webpack-env": "^1.16.0",

为什么我仍然会出现这个错误?我正在使用VSCode,尝试在纱线上重新安装并重新启动VSCode,但无济于事。

有人能帮忙吗?谢谢

编辑:-

我的tsconfig:-

{
"include": [
"client/src/**/*.ts", "client/src/**/*.tsx"
],
"exclude": [
"node_modules",
"/*.*"
],
"compileOnSave": false,
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react",
"lib": ["es5", "es6", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"noEmit": true,
"noImplicitAny": false,
"outDir": "./client/dist/",
"preserveConstEnums": true,
"removeComments": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": false,
"target": "es5",
"types": []
}
}

一个简单的错误-我没有在tconfig.json中包含类型。修复:-

"类型":["webpack env";],

相关内容

最新更新