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:
parent
ca5cbb640a
commit
f699516fdb
5
red.js
5
red.js
@ -175,7 +175,10 @@ if (parsedArgs.userDir) {
|
||||
try {
|
||||
RED.init(server,settings);
|
||||
} 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");
|
||||
} else {
|
||||
console.log("Failed to start server:");
|
||||
|
10
red/red.js
10
red/red.js
@ -27,6 +27,15 @@ var adminApp = null;
|
||||
var server = null;
|
||||
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() {
|
||||
var editorFile = path.resolve(path.join(__dirname,"..","public","red","red.min.js"));
|
||||
try {
|
||||
@ -46,6 +55,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (!userSettings.SKIP_BUILD_CHECK) {
|
||||
checkVersion();
|
||||
checkBuild();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user