webpack-cli与webpack-dev-server兼容性问题
package.json中webpack版本:
"webpack": "^5.19.0",
"webpack-cli": "^4.4.0",
"webpack-dev-server": "^3.11.2"
npm start报错:Error: Cannot find module 'webpack-cli/bin/config-yargs’
原因webpack-cli 4.4.0 与webpack-dev-server 3.11.2不兼容。后者为当前最高版本
解决方案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 webpack-cli@3.3.12
赞 (0)