package.json中webpack版本: "webpack": "^5.19.0", "webpack-cli": "^4.4.0", "webpack-dev-server": "^3.11.2" npm start報(bào)錯(cuò):Error: Cannot find module 'webpack-cli/bin/config-yargs’ 原因webpack-cli 4.4.0 與webpack-dev-server 3.11.2不兼容。后者為當(dāng)前最高版本 解決方案1: 將webpack.config.js中"start"修改如下: "scripts": { "build": "node_modules/.bin/webpack --config webpack.config.js", "start": "webpack serve --config webpack.config.js --open " }, 解決方案2: 卸載webpack-cli 4.4.0 ,,安裝webpack 3.3.12(3.X最高版本) npm uninstall webpack-cli npm install --save-dev [email protected] |
|