{"id":"501e47920f4de663","repo":"webpack/webpack","slug":"hmr-hot-module-replacement-is-disabled","errorCode":null,"errorMessage":"[HMR] Hot Module Replacement is disabled.","messagePattern":"\\[HMR\\] Hot Module Replacement is disabled\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"hot/dev-server.js","lineNumber":91,"sourceCode":"\t\tif (!upToDate() && module.hot.status() === \"idle\") {\n\t\t\tlog(\"info\", \"[HMR] Checking for updates on the server...\");\n\t\t\tcheck();\n\t\t}\n\t};\n\n\tif (typeof EventTarget !== \"undefined\" && hotEmitter instanceof EventTarget) {\n\t\thotEmitter.addEventListener(\n\t\t\t\"webpackHotUpdate\",\n\t\t\t/** @type {EventListener} */\n\t\t\t(handler)\n\t\t);\n\t} else {\n\t\thotEmitter.on(\"webpackHotUpdate\", handler);\n\t}\n\n\tlog(\"info\", \"[HMR] Waiting for update signal from WDS...\");\n} else {\n\tthrow new Error(\"[HMR] Hot Module Replacement is disabled.\");\n}\n","sourceCodeStart":73,"sourceCodeEnd":93,"githubUrl":"https://github.com/webpack/webpack/blob/318421ea8ac81371f5171236a6efb63675576528/hot/dev-server.js#L73-L93","documentation":"hot/dev-server.js is the universal HMR client runtime shipped into the bundle. Its entire body is guarded by `if (module.hot)`; the else branch throws because the client can do nothing useful without the HMR runtime. `module.hot` is injected only when HotModuleReplacementPlugin is active and the build targets HMR.","triggerScenarios":"The dev-server HMR client chunk is included in the entry/output but `module.hot` is undefined at runtime — i.e. HotModuleReplacementPlugin was not applied, devServer.hot was set to false, or a production build accidentally pulled in the HMR client.","commonSituations":"Setting `devServer: { hot: false }` while the client entry still references hot/dev-server; building for production with mode that strips the HMR runtime; a custom setup that injects the WDS client into a non-HMR build; mixing webpack-dev-middleware without the HMR plugin.","solutions":["Keep `devServer.hot` unset or true (the default in development) so the HMR runtime is injected.","Ensure `mode: 'development'` (or manually apply HotModuleReplacementPlugin).","If using webpack-dev-server, let it inject its own client — do not also add hot/dev-server.js to entry manually.","For production builds, exclude the HMR client entirely (no hot/* references)."],"exampleFix":"// webpack.config.js — before\ndevServer: { hot: false },  // client throws: Hot Module Replacement is disabled.\n\n// after\ndevServer: { hot: true },   // or simply omit `hot`","handlingStrategy":"type-guard","validationCode":"// webpack.config.js — make HMR availability explicit\nmodule.exports = {\n  mode: 'development',\n  devServer: { hot: true },\n  plugins: [new webpack.HotModuleReplacementPlugin()],\n};","typeGuard":"// runtime guard for code that conditionally uses the HMR client\nfunction isHotRuntime() {\n  return typeof module !== 'undefined' && module.hot !== null && module.hot !== undefined;\n}","tryCatchPattern":null,"preventionTips":["Let webpack-dev-server inject its own client; do not add hot/dev-server.js to entry manually.","Keep devServer.hot enabled in development and exclude hot/* from production builds.","Confirm HotModuleReplacementPlugin is applied (automatic in mode: 'development')."],"tags":["hmr","runtime","dev-server","client"],"analyzedSha":"318421ea8ac81371f5171236a6efb63675576528","analyzedAt":"2026-08-03T19:39:56.731Z","schemaVersion":2}