Skip to content

Commit

Permalink
fix(cli): shows error message based on package manager
Browse files Browse the repository at this point in the history
shows different error message based on package manager
  • Loading branch information
pranshuchittora committed Apr 27, 2019
1 parent cc64955 commit a3ce273
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,18 @@ For more information, see https://webpack.js.org/api/cli/.`);
options = require("./utils/convert-argv")(argv);
} catch (err) {
// When webpack is not installed and no args passed to the CLI
if (err.code === "MODULE_NOT_FOUND" && err.message === "Cannot find module 'webpack-sources'") {
console.error(
"\n\u001b[31mwebpack not found, please install webpack using\n\t\u001b[33mnpm install --save-dev webpack\n"
);
if (err.code === "MODULE_NOT_FOUND") {
let errorMessage =
"\n\u001b[31mwebpack not found, please install webpack using\n\t\u001b[33mnpm install --save-dev webpack\n";

if (process.env.npm_execpath !== undefined) {
if (process.env.npm_execpath.indexOf("yarn") !== -1) {
errorMessage =
"\n\u001b[31mwebpack not found, please install webpack using\n\t\u001b[33myarn add webpack --dev\n";
}
}

console.error(errorMessage);
return;
}

Expand Down

0 comments on commit a3ce273

Please sign in to comment.