webpack-dev-server Version: 3.1.4
[x] This is a bug
N/A
That webpack-dev-server works with webpack-command.
Or if it specifically needs webpack-cli it's made an explicit dependency.
webpack-dev-server crashes as it's trying to directly access webpack-cli/bin/config-yargs.
> webpack-dev-server --mode development --hot
The CLI moved into a separate package: webpack-cli.
Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D
module.js:549
throw err;
^
Error: Cannot find module 'webpack-cli/bin/config-yargs'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/xxx/node_modules/webpack-dev-server/bin/webpack-dev-server.js:65:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
Create a project with webpack-command and without webpack-cli
I was _just_ about to open this same ticket.
Going forward should we expect webpack-dev-server to only pair with webpack-cli and webpack-command to pair with webpack-serve?
My use case in this situation is not having the time to update my configs for webpack-serve at the moment, so I wanted to retain dev-server while having already moved to webpack-command. Might not be a common enough use case though.
webpack-serve has no dependency on webpack-command. The choice to have webpack-dev-server depend on the CLI for webpack was a poor design decision made many moons ago, but the ecosystem was much more tightly coupled back then, so it wasn't obvious. This does present a problem for people using webpack-dev-server, especially considering the effort to deprecate webpack-cli currently underway.
Additionally, webpack-dev-server won't start in a Yarn Plug'n'Play-enabled project because p'n'p does not allow implicit dependencies:
Error: Package "[email protected]" (via ".../node_modules/webpack-dev-server/bin/webpack-dev-server.js") is trying to require the package "webpack-cli" (via "webpack-cli/bin/config-yargs") without it being listed in its dependencies (webpack, ansi-html, bonjour, chokidar, compression, connect-history-api-fallback, debug, del, express, html-entities, http-proxy-middleware, import-local, internal-ip, ip, killable, loglevel, opn, portfinder, schema-utils, selfsigned, semver, serve-index, sockjs, sockjs-client, spdy, strip-ansi, supports-color, url, webpack-dev-middleware, webpack-log, yargs, webpack-dev-server)
Close in favor https://github.com/webpack/webpack-dev-server/issues/616#issuecomment-466404912. We solve this for v4
Most helpful comment
Additionally,
webpack-dev-serverwon't start in a Yarn Plug'n'Play-enabled project because p'n'p does not allow implicit dependencies: