3

I am using babel-cli for jsx and es6 features to transpile

i have changed my build command

from

"build": "node build",

to

"build": "babel-node build",

Everything was working fine before

But when i run the build command i get this error

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

See the screenshot also

enter image description here

So i should disable react-transform-hmr in production by using env section in Babel configuration

and this is my .babelrc like the instructions

{
  "presets": ["react", "es2015"],
  "env": {
    "development": {
      "plugins": [
        ["transform-object-rest-spread"],
        ["transform-react-display-name"],
        ["react-transform", {
          "transforms": [{
            "transform": "react-transform-hmr",
            "imports": ["react"],
            "locals": ["module"]
          }, {
            "transform": "react-transform-catch-errors",
            "imports": ["react", "redbox-react"]
          }]
        }]
      ]
    },
    "production": {
      "plugins": [
        ["transform-object-rest-spread"],
        ["transform-react-display-name"]
      ]
    }
  }
}

what am i doing wrong? Any recommendation?

Koala7
  • 1,340
  • 7
  • 41
  • 83
  • If you're using gulp: http://stackoverflow.com/questions/28787457/how-can-i-set-an-environment-variable-from-gulp – Guy Jan 16 '17 at 07:55

1 Answers1

3

I had to add NODE_ENV=production to the command

"build": "NODE_ENV=production babel-node build"
Koala7
  • 1,340
  • 7
  • 41
  • 83