score:1

Accepted answer

I faced a similar issue too, what I was doing was I miss spelt a property in my webpack.config.js which is

module.exports = {
  entry: "./src/index.js",
  output: {
    path: path.resolve(__dirname, "dist/assets"),
    filename: "bundle.js",
  },
  devServer: {
    contentBase: path.resolve(__dirname, "dist"),
    publicPath: "/assets", //should provide the path of the served js , img , etc...
  },
};

in the above code I wrongly spet contentBase as contenBase, when I changed it back, it worked well!! You should be looking out for similar issues too

score:2

The problem is that you haven't run yarn/npm install.

score:2

I found an easy solution to this. Change the "start" script in your package.json to the following instead:

"start": "webpack serve --config webpack.config.js --open"

where webpack.config.js is your webpack config file.

I hope it works!

score:4

For me helped to run "webpack-dev-server" after I add the script to "package.json" as "start": "webpack serve --open"


Related Query

More Query from same tag