运行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版本,测试可行
-
卸载当前的 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"
}