Cannot find module 'webpack/bin/config-yargs'

If you're using webpack-cli 4 or webpack 5, change webpack-dev-server to webpack serve.

Example:

"serve": "webpack serve --config config/webpack.dev.js --progress"

You might want also check this comment on GitHub:

NPM package.json scripts are a convenient and useful means to run locally installed binaries without having to be concerned about their full paths. Simply define a script as such:

For webpack-cli 3.x:

"scripts": {   "start:dev": "webpack-dev-server" }

For webpack-cli 4.x:

"scripts": {   "start:dev": "webpack serve" }

Jan 2021

Using webpack 5, just replace the webpack-dev-server command with webpack serve


I've had a similar problem. I think it's related to webpack version. After changing webpack version the latest everything was fine...


Update: March 21

Try to update your webpack dependencies with the following command

npm install --save-dev webpack webpack-cli webpack-dev-server

if it does not work then use as following

I am having these dependencies but I faced the same issue

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

And I found a solution that adding a new script or in your Start Script in package.json worked for me. So you can try this way as well.

"dev": "webpack serve --mode development --env development"