运行webpack-dev-server时Webpack2抛出错误

时间:2017-02-03 15:41:37

标签: javascript webpack webpack-2

我有以下webpack配置文件:

var webpack = require('webpack');

var config = {
    context: __dirname + '/src', // `__dirname` is root of project and `src` is source
    entry: {
        app: './app.js',
    },
    output: {
        path: __dirname + '/dist', // `dist` is the destination
        filename: '[name].bundle.js',
    },
    devServer: {
        open: true, // to open the local server in browser
        contentBase: __dirname + '/src'
    },
    module: {
        rules: [
            {
                test: /\.js$/, //Check for all js files
                    use: [{
                        loader: 'babel-loader',
                        options: { presets: ['es2015'] }
                }]
            }
        ]
    }
};

module.exports = config;

当我运行“webpack-dev-server”时,我收到以下错误:

(webpack)-dev-server / client中的错误?http://localhost:8080 模块构建失败:错误:无法找到相对于目录“/usr/local/lib/node_modules/webpack-dev-server/client/index.js?http:/”

的预设“es2015”

1 个答案:

答案 0 :(得分:0)

在Udemy的教程之后面临同样的问题。添加ImageIcon对我有用。