欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Error: Cannot find module ‘webpack-cli/bin/config-yargs’

程序员文章站 2022-05-13 21:09:45
...

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

解决:

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

安装 webpack-cli 3.* 版本 npm install [email protected] -D

webpack-dev-server ^3 需要安装webpack-cli ^3

// package.json文件
​
"devDependencies": {
    "webpack": "^5.2.0",
    "webpack-cli": "^3.3.12",
    "webpack-dev-server": "^3.11.0"
}