From bd6aca7d9473f37adeadc7df0fd5be6b5358e872 Mon Sep 17 00:00:00 2001
From: Peter Jaszkowiak
Date: Wed, 10 May 2017 15:05:54 -0600
Subject: [PATCH] More friendly error message if module loading fails
---
nodebb | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/nodebb b/nodebb
index 50bcc65fee..2b71185d4e 100755
--- a/nodebb
+++ b/nodebb
@@ -23,12 +23,30 @@ try {
}
}
-require('colors');
-var args = require('minimist')(process.argv.slice(2));
-var request = require('request');
-var semver = require('semver');
-var prompt = require('prompt');
-var async = require('async');
+var minimist;
+var request;
+var semver;
+var prompt;
+var async;
+
+try {
+ require('colors');
+ minimist = require('minimist');
+ request = require('request');
+ semver = require('semver');
+ prompt = require('prompt');
+ async = require('async');
+} catch (e) {
+ process.stdout.write(
+ '\x1b[31mNodeBB could not be initialised because there was an error while loading dependencies.\n' +
+ 'Please run "\x1b[33mnpm install --production\x1b[31m" and try again.\x1b[0m\n\n' +
+ 'For more information, please see: https://docs.nodebb.org/en/latest/installing/os.html\n\n'
+ );
+
+ throw e;
+}
+
+var args = minimist(process.argv.slice(2));
var loaderPath = path.join(__dirname, 'loader.js');
var appPath = path.join(__dirname, 'app.js');