Skip to content

Commit

Permalink
Merge pull request #949 from rishabh3112/fix/not-found
Browse files Browse the repository at this point in the history
fix: module not found error
  • Loading branch information
evenstensberg committed Jun 11, 2019
2 parents 3857b0d + 23eddcb commit 0acd33e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions bin/cli.js
Expand Up @@ -71,18 +71,22 @@ For more information, see https://webpack.js.org/api/cli/.`);
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";
const moduleName = err.message.split("'")[1];
let instructions = "";
let errorMessage = "";

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";
}
if (moduleName === "webpack") {
errorMessage = `\n${moduleName} not installed`;
instructions = `Install webpack to start bundling: \u001b[32m\n $ npm install --save-dev ${moduleName}\n`;

console.error(errorMessage);
Error.stackTraceLimit = 1;
process.exitCode = 1;
return;
if (process.env.npm_execpath !== undefined && process.env.npm_execpath.includes("yarn")) {
instructions = `Install webpack to start bundling: \u001b[32m\n $ yarn add ${moduleName} --dev\n`;
}
Error.stackTraceLimit = 1;
console.error(`${errorMessage}\n\n${instructions}`);
process.exitCode = 1;
return;
}
}

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

0 comments on commit 0acd33e

Please sign in to comment.