2017-02-04 8 views
1

npm install webpack -gでwebpackをグローバルにインストールしました。webpack用のビルドファイルがありません

また、npm install --save-dev babel-loader babel-coreを使用してバベルをインストールしました。

私はビルドファイルを取得するWebPACKの入力はいつでも、私はこの取得:

C:\Sites\Learn-React>webpack

Hash: 5d44ddfc6932f448e682

Version: webpack 2.2.1 Time: 71ms

ERROR in Entry module not found: Error: Can't resolve 'babel' in 'C:\Sites\Learn-React' BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders. You need to specify 'babel-loader' instead of 'babel'.

これを解決することができる方法上の任意のアイデア?

ありがとうございました。

答えて

4

だけでエラーメッセージが言うの操作を行います。

It's no longer allowed to omit the '-loader' suffix when using loaders. You need to specify 'babel-loader' instead of 'babel'. Edit the webpack.config.js accordingly.

根拠がそのautomatic -loader module name extension has been removedです。

+0

はすっごくくらいのuをありがとう!それが指定されたエラーメッセージを欲しい。 – JohnnyDevv

+0

私はPRを送った:https://github.com/webpack/webpack/pull/4226 – simon04

+0

何のためのdatですか? – JohnnyDevv

0

これを解決するには、webpack.config.jsファイルに行き、-loaderをバベルに追加します。以下を参照してください:

//INCORRECT 

    module: { 
    loaders: [ 
     { 
      test: /\.jsx?$/, 
      exclude: /(node_modules)/, 
      loader: 'babel', 
      query: { 
      presets: ['react', 'es2015'] 
      } 
     } 
    ] 
    } 


    //CORRECT 

    module: { 
    loaders: [ 
     { 
      test: /\.jsx?$/, 
      exclude: /(node_modules)/, 
      loader: 'babel-loader', 
      query: { 
      presets: ['react', 'es2015'] 
      } 
     } 
    ] 
    } 
0

モジュールローダーを変更し、接尾辞 '-loader'を必ず使用してください。例えばのためのだから、

const path = require('path'); 

module.exports = { 
entry : './javascript/src/app.js', 
output: { 
    path : path.resolve(__dirname, 'javascript/dist'), 
    filename: 'build.js' 
}, 
module: { 
    loaders: [ 
     { 
      test : /\.js$/, 
      // Wrong 
      // loader : 'babel', 

      //Correct 
      loader : 'babel-loader', 
      exclude: /node_modules/ 
     } 
    ] 
    } 
}; 
関連する問題