Webpack React HMR:locals [0]似乎不是`module`

时间:2016-03-13 21:17:07

标签: webpack babeljs webpack-dev-server webpack-hmr

我没有使用React HMR(和Babel)设置Webpack。在我看来,我的设置类似于我在这里和那里找到的许多例子:

我的package.json开发人员:

{
  // 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"
}

(完成package.json here

我的babelrc配置

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

我的package.json脚本:

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

在我的网站上没有任何加载,我只是得到一个错误

  

未捕获错误:locals [0]似乎不是启用了热模块替换API的module对象。您应该在Babel配置中使用env部分禁用生产中的react-transform-hmr。请参阅自述文件中的示例:https://github.com/gaearon/react-transform-hmr

1 个答案:

答案 0 :(得分:0)

我没有看到Babel 6列为依赖项?您还需要npm安装每个Babel预设。