Error: Cannot find module 'webpack/bin/config-yargs'
时间: 2023-11-14 08:02:01 浏览: 154
引用\[1\]和\[2\]中提到的错误"Error: Cannot find module 'webpack/bin/config-yargs'"通常是由于缺少webpack-cli模块导致的。在webpack4.0以上的版本中,需要安装webpack-cli来解决这个问题。你可以通过运行以下命令来安装webpack-cli:
npm install webpack-cli -g
另外,如果你使用的是webpack@4.32.2版本,并且通过package.json的script去执行webpack-dev-server时出现了相同的错误,你可以尝试卸载旧版本的webpack和webpack-dev-server,然后重新安装最新版本的webpack和webpack-dev-server。你可以使用以下命令来卸载旧版本的webpack和webpack-dev-server:
npm uninstall webpack -g
npm uninstall webpack-dev-server -g
然后,使用以下命令来安装最新版本的webpack和webpack-dev-server:
npm install webpack@latest -g
npm install webpack-dev-server@latest -g
这样应该能够解决你遇到的问题。希望对你有帮助!
#### 引用[.reference_title]
- *1* *2* [Error: Cannot find module ‘webpack/bin/config-yargs‘ 报错原因, webpack@4.X踩的坑~](https://blog.csdn.net/sd19871122/article/details/108743334)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Error: Cannot find module ‘webpack/bin/config-yargs‘ at Function.Module._resolveFilename (intern](https://blog.csdn.net/qq_44866828/article/details/127905821)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文