2017-06-05 11 views
0

私はが反応 - ES6を - 予期しないトークン

ERROR in ./src/components/Header/index.js 
Module build failed: SyntaxError: C:/Users/Gil/Documents/Projects/ecommerce/src/components/Header/index.js: Unexpected token (16:7) 

    14 | } 
    15 | 
> 16 | test =() => { 
    |  ^
    17 |  console.log('pass!'); 
    18 | }; 
    19 | 

iがES6との何かを考えて、このエラーを取得していますが、私は知らない、とにかくここに私の設定です

webpack.config.js

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

package.json

"devDependencies": { 
    "babel-core": "^6.24.1", 
    "babel-loader": "^7.0.0", 
    "babel-preset-es2015": "^6.24.1", 
    "babel-preset-react": "^6.24.1", 
    "react-scripts": "1.0.7" 

ので、私の問題は、私はarrow functionを使用しようとすると、私はこのエラーを取得するには、ですが、私は余分な設定が必要なのでしょうか、私が何か間違ったことをやっていますか?

+0

* *問題が矢印機能付きではありません「私はこのエラーが出る矢印の機能を使用するようにしてください」。これは、 'test = ...;'という代入で行われます。 –

+0

@FelixKlingに感謝します。 – Gil

答えて

2

あなたが

npm install --save-dev babel-plugin-transform-class-properties 

.babelrc内部https://babeljs.io/docs/plugins/transform-class-properties/が必要になります。

"plugins": ["transform-class-properties"] 
+2

理由を説明したいことがあります。 –

+0

また、この提案された言語機能だけでなく、その他のプリセットもあります。例えば、「ステージ2」プリセットには現在、ECMAScriptに含めるパスに沿ってステージ2(4つ)に達したすべての言語機能が含まれています。 –

関連する問題