Skip to content

Commit 8bc0e45

Browse files
committed
Don't rely on webpack's webpack-cli installed check
This doesn't work because it requires webpack-cli if it is installed, thus webpack-cli will startup which we do not want.
1 parent 087bf04 commit 8bc0e45

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

bin/webpack-dev-server.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ if (importLocal(__filename)) {
2424
const Server = require('../lib/Server');
2525
const webpack = require('webpack'); // eslint-disable-line
2626

27-
// webpack has a nice message when webpack-cli is not installed, by requiring it we can also show that
28-
require('webpack/bin/webpack');
27+
try {
28+
require.resolve('webpack-cli');
29+
} catch (e) {
30+
console.error('The CLI moved into a separate package: webpack-cli.');
31+
console.error("Please install 'webpack-cli' in addition to webpack itself to use the CLI.");
32+
console.error('-> When using npm: npm install webpack-cli -D');
33+
console.error('-> When using yarn: yarn add webpack-cli -D');
34+
process.exitCode = 1;
35+
}
2936

3037
function versionInfo() {
3138
return `webpack-dev-server ${require('../package.json').version}\n` +

0 commit comments

Comments
 (0)