Skip to content

"Uncaught Error: [HMR] Hot Module Replacement is disabled." appearing when adding special entry point #1151

Closed
@jdan

Description

@jdan

I'm using webpack for tota11y and absolutely loving it, but I keep running into a problem with HMR and my config.

Following the instructions at http://webpack.github.io/docs/webpack-dev-server.html#hot-mode, I've added webpack/hot/dev-server as an entry point. Running

webpack-dev-server --hot

Everything works as expected, but the problem comes when I build with webpack -p. In doing so, I get the following error when running my bundle in a browser:

Uncaught Error: [HMR] Hot Module Replacement is disabled.

Grepping through my bundle I can see that error message, but why is this hot reloading code in my bundle?

I've since removed that bit from the entry field in my config, and hot reloading seems to work fine. So I remain a bit confused: do I not actually need webpack/hot/dev-server in my config? Are the docs outdated?

I checked around for this error but couldn't find anything, so perhaps my problem runs deeper than that.

Activity

sokra

sokra commented on Jun 15, 2015

@sokra
Member

The docs are wrong... 😢

Just use webpack-dev-server --hot --inline and don't anything special about webpack-dev-server or HMR to your webpack.config.js.

sdras

sdras commented on Jun 22, 2015

@sdras

I'm getting this error as well.

sloria

sloria commented on Jul 14, 2015

@sloria

I am seeing this error as well. Passing --hot --inline to the command line fixes it.

jdan

jdan commented on Jul 19, 2015

@jdan
Author

Thank you @sokra, that worked. Sorry for not updating here!

I'm going to keep this open until a maintainer closes it, hopefully the docs will be updated soon. I would do it myself but I don't know enough about HMR.

chrisdrackett

chrisdrackett commented on Aug 11, 2015

@chrisdrackett

I'm getting the same, I had:

  devServer: {
    hot: true,
    inline: true
  }

in my webpage.config.js and was getting errors when running webpack-dev-server. However, running webpack-dev-server --hot --inline makes everything work as expected.

lubosz

lubosz commented on Sep 5, 2015

@lubosz

I have following in the config:

  devServer: {
    contentBase: "./src/www",
    noInfo: true,
    hot: true,
    inline: true
  }

The browser shows following log:

bundle.js:117 Uncaught Error: [HMR] Hot Module Replacement is disabled.
webpack-dev-server.js:1 [WDS] Hot Module Replacement enabled.

Running webpack-dev-server with --hot --inline does also not help.

patgod85

patgod85 commented on Sep 9, 2015

@patgod85

I have the same issue as @lubosz

sokra

sokra commented on Sep 9, 2015

@sokra
Member

Hot Module Replacement is disabled. means the HotModuleReplacementPlugin is not used.

--hot adds it. (because the CLI have access to your webpack configuration)

hot: true doesn't add it. (because the API doesn't have access to your webpack configuration)

mailaneel

mailaneel commented on Dec 8, 2015

@mailaneel

You have to push new webpack.HotModuleReplacementPlugin() this into your plugins config, webpack-dev-server when used with nodejs api do not add it automatically

var config = require('webpack.config');
config.plugins.push(new webpack.HotModuleReplacementPlugin())
davesnx

davesnx commented on Dec 16, 2015

@davesnx

I change from devServer stuff on the webpack config into --hot --inline in the CLI command and works perfectly. Also, using a express and handling the webpack config works too...

vinhtq

vinhtq commented on Jan 21, 2016

@vinhtq

@mailaneel Thanks! Your solution works!

ace-han

ace-han commented on Feb 18, 2016

@ace-han

@mailaneel Thanks!+1

Amberish

Amberish commented on Feb 23, 2016

@Amberish
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
module.exports = {
  context: path.join(__dirname, "/"),
  devtool: debug ? "inline-sourcemap" : null,
  entry: ["webpack/hot/dev-server", "./src/start.jsx"],
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015', 'stage-0'],
          plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'],
        }
      }
    ]
  },
  output: {
    path: __dirname + "/build/js/",
    filename: "script.js",
    publicPath: "/build/js/"
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
  ],
};

Here is my webpack config. I have following folder structure:

-app
  -build
    -js
       -script.js
  -src
    -start.js

I am compiling start.js in 'src' folder to 'script.js' in 'build/js' folder.

Running it with webpack is compiling exactly as I intended, however running webpack-dev server as:

webpack-dev-server --content-base ./build --hot --inline

is not doing as intended. However, in terminal it is showing compilation.

29 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @chrisdrackett@mailaneel@bebraw@holms@jdan

        Issue actions

          "Uncaught Error: [HMR] Hot Module Replacement is disabled." appearing when adding special entry point · Issue #1151 · webpack/webpack