Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack-Dev-Server keeps looking for src folder

I have a simple html page with one script added and trying to use webpack dev server to load the page, but it keeps returning this error to me ERROR in multi (webpack)-dev-server/client?http://localhost:3000 ./src Module not found: Error: Can't resolve './src' in 'C:\Users\etc\Desktop\etc' and this is my webpack.config.js

const path = require('path');
module.exports = {
  devServer: {
    contentBase: path.resolve(__dirname, 'source/index.html'),
    port: 3000
  }
}

and I'm running this command webpack-dev-server --config ./webpack.config.js

like image 949
Siraj Kakeh Avatar asked Jun 02 '26 04:06

Siraj Kakeh


1 Answers

In default, Webpack4 use ./src to be the enter path. If 'C:\Users\etc\Desktop\etc' doesn't include ./src, you can specify your enter path by webpack.config.js, Could you try this :

const path = require('path');
module.exports = {
  // the enter path
  entry: "YOUR APP PATH",
  devServer: {
    contentBase: path.resolve(__dirname, 'source/index.html'),
    port: 3000
  }
}

And it is easy to config, please see https://webpack.js.org/configuration/

like image 155
Simon.Lay Avatar answered Jun 05 '26 02:06

Simon.Lay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!