webpack/webpack · error · Error
[HMR] Hot Module Replacement is disabled.
Error message
[HMR] Hot Module Replacement is disabled.
What it means
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.
Source
Thrown at hot/dev-server.js:91
if (!upToDate() && module.hot.status() === "idle") {
log("info", "[HMR] Checking for updates on the server...");
check();
}
};
if (typeof EventTarget !== "undefined" && hotEmitter instanceof EventTarget) {
hotEmitter.addEventListener(
"webpackHotUpdate",
/** @type {EventListener} */
(handler)
);
} else {
hotEmitter.on("webpackHotUpdate", handler);
}
log("info", "[HMR] Waiting for update signal from WDS...");
} else {
throw new Error("[HMR] Hot Module Replacement is disabled.");
}
View on GitHub (pinned to 318421ea8a)
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).
Example fix
// webpack.config.js — before
devServer: { hot: false }, // client throws: Hot Module Replacement is disabled.
// after
devServer: { hot: true }, // or simply omit `hot` Defensive patterns
Strategy: type-guard
Validate before calling
// webpack.config.js — make HMR availability explicit
module.exports = {
mode: 'development',
devServer: { hot: true },
plugins: [new webpack.HotModuleReplacementPlugin()],
}; Type guard
// runtime guard for code that conditionally uses the HMR client
function isHotRuntime() {
return typeof module !== 'undefined' && module.hot !== null && module.hot !== undefined;
} Prevention
- 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').
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- [HMR] Hot Module Replacement is disabled.
- [HMR] Hot Module Replacement is disabled.
- [HMR] Hot Module Replacement is disabled.
- check() is only allowed in idle status
- apply() is only allowed in ready status (state: " + currentS
AI-assisted analysis of webpack/webpack@318421ea8a (2026-08-03).
Data as JSON: /data/errors/501e47920f4de663.json.
Report an issue: GitHub.