Reputation: 1922
Im trying to run the following command,
webpack-dev-server
but it throws the following error,
> at Object.Module._extensions..js
> (internal/modules/cjs/loader.js:785:10) at Module.load
> (internal/modules/cjs/loader.js:641:32) at Function.Module._load
> (internal/modules/cjs/loader.js:556:12) at Function.Module.runMain
> (internal/modules/cjs/loader.js:837:10) {
code: 'MODULE_NOT_FOUND', requireStack: [
> '<path_to_project>\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js' ]
> }
Upvotes: 1
Views: 21176
Reputation: 672
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!
Upvotes: 3
Reputation: 626
For me helped to run "webpack-dev-server" after I add the script to "package.json" as "start": "webpack serve --open"
Upvotes: 4
Reputation: 106
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
Upvotes: 1