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

I set up a React project by using webpack, but after setup when I ran the code webpack-dev-server --mode=development the app couldn’t work properly and throw the error: Error: Cannot find module 'webpack-cli/bin/config-yargs' .

After googling for a while, I found out the reason was the versions of these libraries — webpack , webpack-cli and webpack-dev-server — I used couldn’t work together. So I reinstall them and used the older versions which are:

"webpack": "^4.32.2",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.5.1"

And now my setup works as well as expected.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store