已解决 - 问题Cannot find module 'webpack/bin/config-yargs'
程序员文章站
2022-06-01 09:26:58
...
1. 问题:
module.js:538
throw err;
^
Error: Cannot find module 'webpack/bin/config-yargs'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (D:\saic\dev\expressVue\node_modules\[email protected]@webpack-dev-server\bin\webpack-dev-server.js:54:1)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
2. 原因
当webpack与webpack-dev-server版本不匹配时,会出现如上错误。具体版本如下:
"webpack": "^4.35.0",
"webpack-cli": "^3.3.5",
"webpack-dev-server": "^2.11.5"
webpack-dev-server与webpack应该成对匹配使用,对于前者的2.11.5版本,相匹配的webpack为2.2.0~3.0.0版本。
本项目中webpack已经是4.35.0版本了,超前于webpack-dev-server,所以应该升级webpack-dev-server。
3. 解决方法
3.1 卸载旧包,然后升级
cnpm uninstall --save-dev webpack-dev-server
cnpm install --save-dev [email protected]
将cnpm换成npm当然也是可以的。
3.2 修改package.json,然后cnpm install或者npm install
根3.1的方法本质上是一样的
上一篇: 解决 ERROR oslo_service.periodic_task AttributeError: ‘ComputeNode‘ object has no attribute ‘nodename‘
下一篇: Ionic—注册组件开发
推荐阅读
-
【已解决】运行webpack-dev-server时提示Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
webpack5: Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
Webpack 报错:Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
webpack-dev-server 报错 Error: Cannot find module ‘webpack/bin/config-yargs‘
-
webpack——Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
【webpack-dev-server】Error: Cannot find module ‘webpack-cli/bin/config-yargs‘
-
Error: Cannot find module 'webpack-cli/bin/config-yargs' at Function.Module._resolveFilename
-
【webpack】Error: Cannot find module webpack-cli/bin/config-yargs
-
electron-vue项目启动&&解决 process is not defined以及带来的Cannot find module ‘axios‘等问题
-
解决 Node.js Cannot find module 'xxx' 的问题 nodejs