2

I am failing to set up Webpack with React HMR (and Babel). It seems to me that my setup is similar to the many examples I find here and there:

My package.json dev depencencies:

{
  // Only posting stuff that I think is relevant to this here
  "babel-plugin-react-transform": "^2.0.2",
  "babel-preset-react-hmre": "^1.1.1",
  "react-transform-catch-errors": "^1.0.2",
  "react-transform-hmr": "^1.0.4",
  "webpack": "^1.12.14",
  "webpack-dev-middleware": "^1.5.1",
  "webpack-dev-server": "^1.14.1",
  "webpack-hot-middleware": "^2.10.0"
}

(Complete package.json here)

And my babelrc config

{
  "presets": [
    "es2015",
    "react",
    "stage-0",
    "react-hmre"
  ],
  "env": {
    "development": {
      "presets": ["react-hmre"]
    }
  }
}

My package.json scripts:

{
  "start": "NODE_ENV=development webpack-dev-server --hot --inline --config webpack.config.dev.js",
}

On my website nothing loads and I simply get an error

Uncaught Error: locals[0] does not appear to be a module object with Hot Module replacement API enabled. You should disable react-transform-hmr in production by using env section in Babel configuration. See the example in README: https://github.com/gaearon/react-transform-hmr

loganfsmyth
  • 156,129
  • 30
  • 331
  • 251
Lukas
  • 9,752
  • 15
  • 76
  • 120
  • http://stackoverflow.com/questions/36153628/why-does-production-build-of-react-app-with-webpack-and-babel-use-wrong-develo/37417093#37417093 – Mati May 24 '16 at 14:55

1 Answers1

0

I don't see Babel 6 listed as a dependency? You also need to npm install each of your Babel presets.

Joe Bruno
  • 417
  • 1
  • 4
  • 11
  • Sorry, I had not made myself clear—I only *posted* the relevant parts, I included Babel and React etc… . This is my complete `package.json` https://gist.github.com/LukasBombach/37f7f7aa7bc1e4ea6516 – Lukas Mar 15 '16 at 06:23