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

出现原因

安装 webpack 5.*, webpack-cli 4.*, webpack-dev-server 3.11.*, 运行时导致命令行报错 Error: Cannot find module 'webpack-cli/bin/config-yargs'

"dev": "webpack-dev-serve"

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

解决方案

使用 webpack serve

"dev": "webpack serve"

参考

webpack-cli issuse