Cannot find module 'webpack/bin/config-yargs'
时间: 2023-11-14 10:01:52 浏览: 144
手动解决Cannot find module '@sentry/webpack-plugin'等问题
5星 · 资源好评率100%
根据你提供的引用内容,报错信息"Cannot find module 'webpack/bin/config-yargs'"是由于webpack3.x的版本与webpack-dev-server3.x的版本不兼容导致的\[1\]。解决这个问题的方法是卸载局部或者全局的webpack-dev-server,然后安装指定版本的webpack-dev-server@2.9.7\[1\]。另外,需要注意的是,webpack-dev-server将打包生成的bundle.js文件托管到电脑的内存中,而不是实际的物理磁盘上\[1\]。因此,在引用文件时,路径应该直接从根目录下引用,例如<script src='/bundle.js'></script>\[1\]。
此外,还有一种可能的原因是webpack-cli升级到了4,不再支持webpack-dev-server命令\[2\]。如果是这种情况,可以尝试降低webpack的版本,删除高版本的webpack并安装低版本的webpack,例如npm install webpack@3.0.0 -g\[3\]。
综上所述,解决"Cannot find module 'webpack/bin/config-yargs'"的方法是卸载并安装适配版本的webpack-dev-server,或者降低webpack的版本。
#### 引用[.reference_title]
- *1* [解决报错Cannot find module 'webpack-cli/bin/config-yargs'](https://blog.csdn.net/sxs7970/article/details/88746939)[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^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Error: Cannot find module ‘webpack/bin/config-yargs’ 报错原因以及解决办法](https://blog.csdn.net/it___is_/article/details/115407409)[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^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [Error: Cannot find module ‘webpack-cli/bin/config-yargs‘ 报错的解决方法?](https://blog.csdn.net/weixin_46409887/article/details/115696108)[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^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文