Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): throws err when no args passed #862

Merged
merged 15 commits into from
Jun 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ For more information, see https://webpack.js.org/api/cli/.`);
try {
options = require("./utils/convert-argv")(argv);
} catch (err) {
if (err.code === "MODULE_NOT_FOUND") {
let errorMessage =
"\n\u001b[31mwebpack not installed, consider installing it using \n\u001b[32mnpm install --save-dev webpack\n";

if (process.env.npm_execpath !== undefined && process.env.npm_execpath.includes("yarn")) {
errorMessage =
"\n\u001b[31mwebpack not installed, consider installing it using \n\u001b[32myarn add webpack --dev\n";
}

console.error(errorMessage);
Error.stackTraceLimit = 1;
process.exitCode = 1;
return;
evenstensberg marked this conversation as resolved.
Show resolved Hide resolved
evenstensberg marked this conversation as resolved.
Show resolved Hide resolved
evenstensberg marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fine, as long as we're doing it in the scope of only MODULE_NOT_FOUND

}

if (err.name !== "ValidationError") {
throw err;
}
Expand Down