2016-07-20 6 views
7

バベルを使用しようとすると次のエラーが発生します。あなたは、これらのプリセットを使用するように構成されたバベルを持っている必要がありエラー:ディレクトリに対してプリセット "es2015"を見つけられませんでした

Error: Couldn't find preset "es2015" relative to directory

webpack.config.js

module.exports = { 
    entry: './main.js', 
    ourput: { 
     path:'./', 
     filename:'index.js' 
    }, 
    devServer:{ 
     inline:true, 
     port:3333 
    }, 
    module:{ 
     loaders:[ 
      { 
       test:/\.js$/, 
       exclude:/node_modules/, 
       loader:'babel', 
       query:{ 
        presets:['es2015','react'] 
       } 
      } 
     ] 
    } 
} 

package.json

{ 
    "name": "es6-react-setup", 
    "version": "1.0.0", 
    "main": "main.js", 
    "dependencies": { 
    "babel-core": "^6.11.4", 
    "babel-preset-es2015": "^6.9.0", 
    "babel-preset-react": "^6.11.1", 
    "babel-loader": "^6.2.4", 
    "react": "^15.2.1", 
    "react-dom": "^15.2.1", 
    "webpack": "^1.13.1" 
    }, 
    "devDependencies": {}, 
    "scripts": { 
    "start": "webpack-dev-server" 
    }, 
    "author": "", 
    "license": "ISC", 
    "description": "" 
} 

ターミナル出力 Terminal output

+0

[エラー:ディレクトリ "/Users/username"](http://stackoverflow.com/questions/34819473/error-couldnt-find-preset-es2015-html)に対するプリセット" es2015 "が見つかりませんでした。相対ディレクトリユーザ - ユーザ名) –

答えて

10

。あなたは、あなたが代わりに.babelrcファイルを持つことができ、あなたのpackage.json

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

にこれを追加することができます。

https://babeljs.io/docs/usage/babelrc/

3

この

npm install babel-preset-es2015

npm install babel-preset-react

npm install babel --save-dev

これは私のために働いてみてください。

関連する問題