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

问题:webpack 打包报错

  • 使用webpack 对项目打包管理
  • 运行命令:npm run dev
  • 报错:
Error: Cannot find module 'webpack-cli/bin/config-yargs'
Cannot find module 'webpack-cli/bin/config-yargs'_第1张图片
image.png
  • 查看package.json文件
"devDependencies": {
    "webpack": "^5.2.0",
    "webpack-cli": "^4.1.0",
    "webpack-dev-server": "^3.11.0"
}

在 github 上找到问题:

Cannot find module 'webpack-cli/bin/config-yargs'_第2张图片
image.png

解决方案:

  • 卸载 webpack-cli:npm uninstall webpack-cli
  • 安装 webpack-cli 3.* 版本: npm install webpack-cli@3 -D

你可能感兴趣的:(Cannot find module 'webpack-cli/bin/config-yargs')