1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add node.js version check on startup

This commit is contained in:
Nick O'Leary 2017-01-12 10:40:04 +00:00
parent ca5cbb640a
commit f699516fdb
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 14 additions and 1 deletions

5
red.js
View File

@ -175,7 +175,10 @@ if (parsedArgs.userDir) {
try { try {
RED.init(server,settings); RED.init(server,settings);
} catch(err) { } catch(err) {
if (err.code == "not_built") { if (err.code == "unsupported_version") {
console.log("Unsupported version of node.js:",process.version);
console.log("Node-RED requires node.js v4 or later");
} else if (err.code == "not_built") {
console.log("Node-RED has not been built. See README.md for details"); console.log("Node-RED has not been built. See README.md for details");
} else { } else {
console.log("Failed to start server:"); console.log("Failed to start server:");

View File

@ -27,6 +27,15 @@ var adminApp = null;
var server = null; var server = null;
var apiEnabled = false; var apiEnabled = false;
function checkVersion() {
var semver = require('semver');
if (!semver.satisfies(process.version,">=4.0.0")) {
var e = new Error("Unsupported version of node.js");
e.code = "unsupported_version";
throw e;
}
}
function checkBuild() { function checkBuild() {
var editorFile = path.resolve(path.join(__dirname,"..","public","red","red.min.js")); var editorFile = path.resolve(path.join(__dirname,"..","public","red","red.min.js"));
try { try {
@ -46,6 +55,7 @@ module.exports = {
} }
if (!userSettings.SKIP_BUILD_CHECK) { if (!userSettings.SKIP_BUILD_CHECK) {
checkVersion();
checkBuild(); checkBuild();
} }