Error: Cannot find module 'webpack-cli/bin/config-yargs'

Solution 1:

You could try changing webpack-dev-server to webpack serve in your npm run script inside package.json

Solution 2:

For some reason the webpack team changed the command to webpack serve Change your package.json:

"start": "webpack serve"

Ref: https://github.com/webpack/webpack-dev-server/issues/2759

The version I am using:

"webpack": "^5.10.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0"

Solution 3:

I agree that you have to upgrade from webpack 3 to 4, but specifically these are the steps I had to do, first, because webpack-cli has been split out into a separate package:

$ npm install webpack webpack-cli --save-dev

As explained here: https://webpack.js.org/guides/getting-started/#basic-setup

Solution 4:

To fix it just do 2 things.

  1. Install npm i webpack-cli @webpack-cli/init
  2. Add this to your package.json:
    "scripts": {
      "start": "webpack-cli serve --mode development"
    },
    

Done!

Solution 5:

Delete package-lock.json file. Change following in package.json.

"webpack": "^4.32.2",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.11.0"

Run npm install