欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

解决 => Cannot find module ‘webpack-cli/bin/config-yargs

程序员文章站 2022-06-01 09:27:22
...

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! [email protected] start: `webpack-dev-server --mode=development --config ./build/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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",

参考 =>
https://github.com/webpack/webpack-dev-server/issues/2759

 "start": "webpack serve --mode development --config ./build/webpack.config.js",