webpack-dev-server 报错 Error: Cannot find module ‘webpack/bin/config-yargs‘
程序员文章站
2022-07-12 19:34:36
...
Error: Cannot find module 'webpack/bin/config-yargs' 报错 解决
> [email protected] dev G:\000Code\10\11\demo70
> webpack-dev-server --port 3000
internal/modules/cjs/loader.js:1033
throw err;
^
Error: Cannot find module 'webpack/bin/config-yargs'
Require stack:
- G:\000Code\10\11\demo70\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1030:15)
at Function.Module._load (internal/modules/cjs/loader.js:899:27)
at Module.require (internal/modules/cjs/loader.js:1090:19)
at require (internal/modules/cjs/helpers.js:75:18)
at Object.<anonymous> (G:\000Code\10\11\demo70\node_modules\webpack-dev-server\bin\webpack-dev-server.js:56:1)
at Module._compile (internal/modules/cjs/loader.js:1201:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
at Module.load (internal/modules/cjs/loader.js:1050:32)
at Function.Module._load (internal/modules/cjs/loader.js:938:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'G:\\000Code\\10\\11\\demo70\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `webpack-dev-server --port 3000`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2020-11-19T02_43_49_770Z-debug.log
PS G:\000Code\10\11\demo70> npm uninstall webpack webpack-cli webpack-dev-server
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
removed 535 packages in 8.81s
报错原因 : webpack-dev-server 的版本和 webpack 发生冲突
解决办法 :
1 : 先把冲突的 webpack webpack-cli webpack-dev-server 全部卸载掉
npm uninstall webpack webpack-cli webpack-dev-server
2 : npm安装指定版本
npm i -D [email protected] [email protected] [email protected]
3 : 重新运行 npm run dev
推荐阅读
-
webpack-dev-server config.js Cannot find module
-
【已解决】运行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
-
vue项目报错:”Module build failed: Error: Cannot find module ‘node-sass‘报错问题