运行npm run dev
遇到的问题:Error: Cannot find module 'webpack-cli/bin/config-yargs'
// 当前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
// package.json文件 "devDependencies": { "webpack": "^5.2.0", "webpack-cli": "^3.3.12", "webpack-dev-server": "^3.11.0" }
思考:
遇到问题首先到github项目的Issues中,检索一下相关问题,比在百度谷歌上直接搜索非官方解决方案好得多。