解决 => Error: Cannot find module 'webpack-cli/bin/config-yargs'(麻烦老师看下是否有问题)
来源:11-3 Webpack配置优化
THEEND0123
2020-11-17
Error: Cannot find module ‘webpack-cli/bin/config-yargs’ =>
> internal/modules/cjs/loader.js:965
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
Require stack:- H:\ld\task\code\Webpack\02\node_modules\webpack-dev-server\bin\webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)
at Function.Module._load (internal/modules/cjs/loader.js:838:27)
at Module.require (internal/modules/cjs/loader.js:1022:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (H:\ld\task\code\Webpack\02\node_modules\webpack-dev-server\bin\webpack-dev-server.js:65:1)
at Module._compile (internal/modules/cjs/loader.js:1118:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
at Module.load (internal/modules/cjs/loader.js:982:32)
at Function.Module._load (internal/modules/cjs/loader.js:875:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'H:\\ld\\task\\code\\Webpack\\02\\node_modules\\webpack-dev-server\\bin\\webpack-dev-server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 6xd-es-cli@1.0.0 start: `webpack-dev-server --mode=development --config ./build/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 6xd-es-cli@1.0.0 start 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\6XD\AppData\Roaming\npm-cache\_logs\2020-11-17T13_49_48_053Z-debug.log
原因webpack版本的问题:
我的版本是
"webpack": "^5.4.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0",
"start": "webpack serve --mode development --config ./build/webpack.config.js",
写回答
2回答
-
Suspendz
2021-02-01
安装低版本(3.10.1),然后把命令行改成webpack server --mode==development --config ./build/webpack.config.js就行了。
我尝试安装和老师一样的3.10.1,用webpack-dev-server命令依然是有问题的
012021-05-26 -
谢成
2020-11-18
建议按照视频中的过程来一步步操作。
00
相似问题