2017-01-09 3 views
1

Я пишу одно приложение в ReactJs. Я использую webpack. Когда я попытался запустить мое приложение, у меня какое-то странное исключение, которое я не могу объяснить, в это время:Странное исключение по процессу написания некоторых приложений в 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) 

@ мульти главного

+0

Приложить package.json, может быть, ваш index.js тоже. Очень сложно помочь вам только с этой ошибкой. Благодарю. –

+0

Попробуйте установить версию 3.0 или более поздней версии –

ответ

0

Это очень трудно сказать, без дополнительного исходного кода но я бы предположил, что вы забыли использовать new, когда вы добавили модуль hot-loader. Оно должно быть:

plugins: [ 
    new webpack.HotModuleReplacementPlugin() 
] 

Предполагая, что ваша ошибка приходит отсюда: https://github.com/gaearon/react-hot-loader/blob/master/index.js#L9-L11, единственный способ, которым я могу думать, что this будет undefined, если вы не в состоянии дать ему надлежащий контекст, не используя new

0

Да, конечно. Там мой 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

{ 
    "name": "Soundcloud-React", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "start": "webpack-dev-server --progress --colors --hot --config ./webpack.config.js", 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "keywords": [], 
    "author": "", 
    "license": "ISC", 
    "babel": { 
    "presets": [ 
     "es2016", 
     "react", 
     "stage-2" 
    ], 
    "plugins": [ 
    "react-hot-loader", 
    "babel"] 
    }, 
    "devDependencies": { 
    "babel-core": "^6.21.0", 
    "babel-loader": "^6.2.10", 
    "babel-preset-es2016": "^6.16.0", 
    "babel-preset-react": "^6.16.0", 
    "babel-preset-stage-2": "^6.18.0", 
    "react-hot-loader": "^1.3.1", 
    "webpack": "^1.14.0", 
    "webpack-dev-server": "^1.16.2" 
    }, 
    "dependencies": { 
    "react": "^15.4.2", 
    "react-dom": "^15.4.2" 
    } 
}