question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: "Hot Module Replacement (HMR) is not enabled!"

See original GitHub issue

I’m getting this error:

[React Refresh] Hot Module Replacement (HMR) is not enabled! React Refresh requires HMR to function properly.

I’m using electron-forge to drive the webpack config, and it uses webpack-dev-server with hot: true internally. Apparently, there’s a kind of an init ordering issue, but react-refresh-webpack-plugin wrongly detects that hot reload is not enables.

A simple demonstration of the incorrectness of this behavior is adding new webpack.HotModuleReplacementPlugin() makes the error go away and the page to load, but upon the refresh the typical stack overflow error caused by two instances of hot reload plugin running occurs.

Our setup worked correctly before the update, this seems like a bug. It would be great to have an option to opt-out of this check entirely.

Unfortunately, disabling hot at the webpack-dev-server end is not an option for us, since it’s under control of the electron-forge.

Webpack we’re using is v4. Version 0.3.3 works, version 0.4.1 has this issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
silkfirecommented, Aug 11, 2020

I got it to work. For some reason I had accidentally removed const webpackHotMiddleware = require('webpack-hot-middleware') as I thought it part of the react-hot-loader package, which I in fact was replacing.

Perhaps the guide could state the importance of enabling HMR, as I did not get it to work by just blindly following it?

webpack.config.js (dev)

const webpack = require('webpack');
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');

...

entry: {
    app: ['webpack-hot-middleware/client'],
},

...

plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new ReactRefreshPlugin(),
],
1reaction
pmmmwhcommented, Aug 7, 2020

I was debating to either use forceEnable as a way to suppress checks, or just add a forceSuppressErrors flag. Maybe we could go with the latter then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught Error: [HMR] Hot Module Replacement is disabled
My understanding of using Hot Module Replacement is that its designed for making life easier during development, it should not be used in ......
Read more >
Hot Module Replacement - webpack
Hot Module Replacement (or HMR) is one of the most useful features offered by webpack. It allows all kinds of modules to be...
Read more >
Hot Module Replacement - SurviveJS
Hot Module Replacement (HMR) builds on top of the WDS. It enables an interface that makes ... You should not enable HMR for...
Read more >
Webpack's Hot Module Replacement Feature Explained
Hot Module Replacement is a feature that enables you to see code changes in the browser without having to refresh it, allowing you...
Read more >
Enabling Hot Module Replacement (HMR) in Angular 6
Hot Module Replacement (HMR) is a key webpack feature that is not enable by default in Angular. It allows for modules to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found