diff --git a/packages/webpack-cli/lib/webpack-cli.js b/packages/webpack-cli/lib/webpack-cli.js index 4ce7ad3254f..0d68efbf47e 100644 --- a/packages/webpack-cli/lib/webpack-cli.js +++ b/packages/webpack-cli/lib/webpack-cli.js @@ -940,8 +940,15 @@ class WebpackCLI { const command = findCommandByName(name); if (!command) { - this.logger.error(`Can't find and load command '${name}'`); - this.logger.error("Run 'webpack --help' to see available commands and options"); + const builtInCommandUsed = externalBuiltInCommandsInfo.find( + (command) => command.name.includes(name) || name === command.alias, + ); + if (typeof builtInCommandUsed !== 'undefined') { + this.logger.error(`For using '${name}' command you need to install '${builtInCommandUsed[0].pkg}' package`); + } else { + this.logger.error(`Can't find and load command '${name}'`); + this.logger.error("Run 'webpack --help' to see available commands and options"); + } process.exit(2); }