webpack编译遇到的问题:Error: Cannot find module 'webpack-cli/bin/config-yargs'

运行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"

 

  解决:

  1. 卸载当前的 webpack-cli npm uninstall webpack-cli

  2. 安装 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中,检索一下相关问题,比在百度谷歌上直接搜索非官方解决方案好得多。

posted on 2020-11-02 10:58  zwjphp  阅读(451)  评论(0编辑  收藏  举报