2017-02-10 22 views
2

私はreact、redux、firebaseを統合したプロジェクトに取り組んでいます。反応を還元する - firebaseは便利なツールのようです。しかし、コードは正常に遵守されていません。以下はwebpack.config.js、.babelrc、およびindex.jsというエラーです。事前に助けてくれてありがとう。react-redux-firebase "このファイルタイプを扱うには適切なローダーが必要な場合があります。"

エラーメッセージ:

ERROR in ./~/react-redux-firebase/src/connect.js 
Module parse failed: 
/Users/xiqianglin/ucsdflyers/node_modules/react-redux-firebase/src/connect.js 
Unexpected token (43:24) You may need an appropriate loader to handle this file type. 
|  } 
| 
|  static contextTypes = { 
|  store: PropTypes.object.isRequired 
|  }; 
@ ./~/react-redux-firebase/src/index.js 1:0-31 @ ./src/index.js @ multi ./src/index.js 


/****And there are other similar errors, all "...appropriate loader..." ***/ 

webpack.config.js

var HtmlWebpackPlugin = require('html-webpack-plugin'); 
var HTMLWebpackPluginConfig = new HtmlWebpackPlugin({ 
    template: __dirname + '/src/index.html', 
    filename: 'index.html', 
    inject: 'body' 
}); 

module.exports = { 
entry: [ 
     './src/index.js' 
     ], 

module: { 
     loaders: [ 
        {test: /\.js$/, 
        exclude: /node_modules/, 
        loader:'babel-loader'} 
       ] 
     }, 

resolve: { 
    extensions: [".js", ".jsx", ".es6"] 
}, 

output: { 
     filename: "index_bundle.js", 
     path: __dirname + '/dist' 
     }, 

plugins: [HTMLWebpackPluginConfig] 
}; 

.babelrc

{ 
    "presets": ["react", "es2015"] 
} 

index.js

/*Other Imports...*/ 
import { firebaseStateReducer } from 'react-redux-firebase'; //This is the line causing error 

ReactDOM.render(
    <Provider> 
    <App/> 
    </Provider>, 
    documeng.getElementById('app') 
) 

答えて

0

あなたのことを確認してください。npm install - すべてのあなたの依存関係。

その後、問題が解決しない場合は、この試してみてください。

npm install babel-preset-es2015

を、あなたが特定のノードモジュールを含める必要がある場合は、あなたのexclude

{ 
    test: /\.js$/, 
    exclude: /node_modules/, 
    loader:'babel-loader', 
    query: { 
    presets: ['es2015'] 
    } 
} 

後es2015のクエリを追加ソースディレクトリとその特定のノードモジュールフォルダをbabel-loaderで解析するようにしてください。だからではなく、exclude: /node_modules/,の は、私が「es2015」の両方を持っていると.babelrcに「反応」

include: [ 
    path.resolve(__dirname, "src"), 
    path.resolve(__dirname, "node_modules/react-redux-firebase") 
    ] 
+0

を試してみてください。あなたが提案した通りにやっても、エラーが続く – BeLikeJo

+0

私はあなたが試すことができる別のもので私の答えを更新しました。 node_modulesフォルダをすべて除外するのではなく、 'react-redux-firebase'をインクルードする必要があるかもしれません。 –

+0

フォローアップのコメントありがとうございます。残念ながら、私は試しても、エラーは解決しません。 – BeLikeJo

関連する問題