npm run dev:Cannot find module ‘webpack-cli/bin/config-yargs’(webpack)
当前package.json文件:
"devDependencies": {
"webpack": "^5.2.0",
"webpack-cli": "^4.1.0",
"webpack-dev-server": "^3.11.0"
}
问题解决:
问题解决参考: 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 npm uninstall webpack-cli
- 安装 webpack-cli 3.* 版本 npm install webpack-cli@3 -D
3.当前package.json文件:
"devDependencies": {
"webpack": "^5.3.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
}
思考:
遇到问题首先到github项目的Issues中,检索一下相关问题,比在百度谷歌上直接搜索非官方解决方案好得多。