在ReactJs中编写某些应用程序的过程中出现了奇怪的异常

在ReactJs中编写某些应用程序的过程中出现了奇怪的异常,reactjs,webpack,webpack-dev-server,Reactjs,Webpack,Webpack Dev Server,我正在用ReactJs编写一个应用程序。我使用网页包。当我尝试启动我的应用程序时,我遇到了一些奇怪的异常,我现在无法解释: ERROR in ./src/index.js Module build failed: TypeError: Cannot read property 'cacheable' of undefined at module.exports (/Users/rogozindaniil/Documents/sc-react-redux/node_modules/reac

我正在用ReactJs编写一个应用程序。我使用网页包。当我尝试启动我的应用程序时,我遇到了一些奇怪的异常,我现在无法解释:

ERROR in ./src/index.js
  Module build failed: TypeError: Cannot read property 'cacheable' of undefined
  at module.exports (/Users/rogozindaniil/Documents/sc-react-redux/node_modules/react-hot-loader/index.js:9:11)
  at Function.memoisePluginContainer (/Users/rogozindaniil/Documents/sc-react-redux/node_modules/babel-core/lib/transformation/file/options/option-manager.js:109:13)
  at Function.normalisePlugin (/Users/rogozindaniil/Documents/sc-react-redux/node_modules/babel-core/lib/transformation/file/options/option-manager.js:142:32)
  at /Users/rogozindaniil/Documents/sc-react-redux/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:30
  at Array.map (native)
  at Function.normalisePlugins (/Users/rogozindaniil/Documents/sc-react-redux/node_modules/babel-core/lib/transformation/file/options/option-manager.js:154:20)
  at OptionManager.mergeOptions (/Users/rogozindaniil/Documents/sc-react-redux/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:36)
  at OptionManager.init (/Users/rogozindaniil/Documents/sc-react-redux/node_modules/babel-core/lib/transformation/file/options/option-manager.js:374:12)
  at File.initOptions (/Users/rogozindaniil/Documents/sc-react-redux/node_modules/babel-core/lib/transformation/file/index.js:216:65)
  at new File (/Users/rogozindaniil/Documents/sc-react-redux/node_modules/babel-core/lib/transformation/file/index.js:139:24)

@multi-main

如果没有更多的源代码,很难说,但是我可以想象,当您添加
热加载程序
模块时,您忘记使用
new
。应该是:

plugins: [
  new webpack.HotModuleReplacementPlugin()
]

假设您的错误来自这里:,我认为
将是
未定义的
的唯一方法是,如果您没有使用
new
为其提供适当的上下文,那么如果没有更多的源代码,很难说,但是我可以想象,当您添加
热加载程序
模块时,您忘记使用
new
。应该是:

plugins: [
  new webpack.HotModuleReplacementPlugin()
]

假设您的错误来自这里:,我认为
将是
未定义的
的唯一方法是,如果您没有使用
new
为它提供正确的上下文,当然是。这是我的index.js文件:

import React from 'react';
import ReactDOM from 'react-dom';
import Stream from './components/Stream';

const tracks = [
  {
    title: 'Track 1'
  },
  {
    title: 'Track'
  }
];

ReactDOM.render(
  <Stream tracks={tracks} />,
  document.getElementById('app')
);

当然可以。这是我的index.js文件:

import React from 'react';
import ReactDOM from 'react-dom';
import Stream from './components/Stream';

const tracks = [
  {
    title: 'Track 1'
  },
  {
    title: 'Track'
  }
];

ReactDOM.render(
  <Stream tracks={tracks} />,
  document.getElementById('app')
);

附加package.json,也可以附加index.js。仅凭这个错误是很难帮助你的。谢谢。请尝试安装3.0.0或更高版本的react hot roaderAttach your package.json,也可以安装index.js。仅凭这个错误是很难帮助你的。谢谢。请尝试安装3.0.0或更高版本的react hot roader