1

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'  ] 
> }
1
  • thaaanks, now it works. but can you explain to me why i had to run npm/yarn install? if before this, i installed the dependency Commented Jul 3, 2019 at 12:55

4 Answers 4

4

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

Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

3

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!

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.