added logic to catch bad installs

In cases where the nodebb executable is run before `npm i`, NodeBB
will now emit a friendly message instead of a scary one.
v1.18.x
Julian Lam 9 years ago
parent eb28e178a7
commit c8bbbda22f

@ -1,14 +1,25 @@
#!/usr/bin/env node
var colors = require('colors'),
cproc = require('child_process'),
argv = require('minimist')(process.argv.slice(2)),
fs = require('fs'),
path = require('path'),
request = require('request'),
semver = require('semver'),
prompt = require('prompt'),
async = require('async');
try {
var colors = require('colors'),
cproc = require('child_process'),
argv = require('minimist')(process.argv.slice(2)),
fs = require('fs'),
path = require('path'),
request = require('request'),
semver = require('semver'),
prompt = require('prompt'),
async = require('async');
} catch (e) {
if (e.code === 'MODULE_NOT_FOUND') {
process.stdout.write('NodeBB could not be started because it\'s dependencies have not been installed.\n');
process.stdout.write('Please ensure that you have executed "npm install --production" prior to running NodeBB.\n\n');
process.stdout.write('For more information, please see: https://docs.nodebb.org/en/latest/installing/os.html\n\n');
process.stdout.write('Could not start: ' + e.code + '\n');
process.exit(1);
}
}
var getRunningPid = function(callback) {
fs.readFile(__dirname + '/pidfile', {

Loading…
Cancel
Save