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

  1. // package.json
  2. {
  3. "devDependencies": {
  4. "webpack": "^5.2.0",
  5. "webpack-cli": "^4.1.0",
  6. "webpack-dev-server": "^3.11.0"
  7. }
  8. }

参考:Error: Cannot find module ‘webpack-cli/bin/config-yargs’ #1948

If you upgrade webpack to 5. , and webpack cli to 4. , an error will be reported: Error: Cannot find module ‘webpack-cli/bin/config-yargs’ Temporary solution: Back off webpack cli to version 3. * for example:

“webpack-cli”: “^ 3.3.12”

安装 webpack-cli 3. 版本 *npm install webpack-cli@3 -D