ERROR in multi (webpack)-dev-server/client?http://localhost:8080 ./src when use webpack4.2.0

xudengwei picture xudengwei · Apr 1, 2018 · Viewed 17.6k times · Source

when i use webpack4.2.0, play 'run start', show errors follow:

WARNING in configuration The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment.

ERROR in multi (webpack)-dev-server/client?http://localhost:8001 ./src Module not found: Error: Can't resolve './src' in '/Users/xudengwei/projects/xudengwei/myOpenGithub/angular5-scaffold' @ multi (webpack)-dev-server/client?http://localhost:8001 ./src ℹ 「wdm」: Failed to compile.

#

my configure as follow: webpack.common.js:

webpack.dev.js:

var path = require('path');
var webpackMerge = require('webpack-merge');
var commonConfig = require('./webpack.common.js');

module.exports = webpackMerge(commonConfig, {
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name].js',
        chunkFilename: '[id].chunk.js'
    },
    module: {
        rules: []
    },
    plugins: [    
        new HtmlWebpackPlugin({
            template: './index.html',
            inject: true
        })
    ],
    devServer: {
        devServer: {
            contentBase: './dist'
        },
    }
});

someone knows the reason?thanks

Answer

Adi Winata picture Adi Winata · Apr 4, 2018

I also just get this error like you got and its was solved when i specify webpack config file. Try to add --config when you run webpack-dev-server. Ex. webpack-dev-server --config webpack.dev.js