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
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With