From 75445859083716ffedf9ab4efb5de1b2f3d0cf09 Mon Sep 17 00:00:00 2001 From: muxator Date: Fri, 27 Jul 2018 01:45:06 +0200 Subject: [PATCH] runtime: enforce minimal node version to 6.9.0 Etherpad 1.6.6 does not run on node <= 5 already. Node 6.9 is the first LTS release in the 6 series, and comes with npm 3.10.8. Declarations in package.json are advisory unless the user has set `engine-strict` config flag. Updated the docs accordingly. --- README.md | 5 ++++- doc/plugins.md | 2 +- src/node/server.js | 6 ++++++ src/node/utils/NodeVersion.js | 37 +++++++++++++++++++++++++++++++++++ src/package.json | 4 ++-- 5 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 src/node/utils/NodeVersion.js diff --git a/README.md b/README.md index 8941c6fb..5052d916 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,9 @@ Etherpad is a really-real time collaborative editor scalable to thousands of sim # Installation +## Requirements +- `nodejs` >= **6.9.0** + ## Uber-Quick Ubuntu ``` curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - @@ -21,7 +24,7 @@ You'll need gzip, git, curl, libssl develop libraries, python and gcc. - *For Fedora/CentOS*: `yum install gzip git curl python openssl-devel && yum groupinstall "Development Tools"` - *For FreeBSD*: `portinstall node, npm, curl, git (optional)` -Additionally, you'll need [node.js](https://nodejs.org) installed. +Additionally, you'll need [node.js](https://nodejs.org) installed (minimum required Node version: **6.9.0**). Ideally, the latest stable version is preferred. Please note that the packages offered on some operating systems are outdated. In those cases, we recommend installing nodejs from official archives or compiling it from source (avoiding yum/apt). **As any user (we recommend creating a separate user called etherpad):** diff --git a/doc/plugins.md b/doc/plugins.md index e5b00408..cf72c98f 100644 --- a/doc/plugins.md +++ b/doc/plugins.md @@ -99,7 +99,7 @@ Your plugin must also contain a [package definition file](https://docs.npmjs.com "author": "USERNAME (REAL NAME) ", "contributors": [], "dependencies": {"MODULE": "0.3.20"}, - "engines": { "node": ">= 0.6.0"} + "engines": { "node": ">= 6.9.0"} } ``` diff --git a/src/node/server.js b/src/node/server.js index 1907c29f..8972f252 100755 --- a/src/node/server.js +++ b/src/node/server.js @@ -24,6 +24,7 @@ var log4js = require('log4js') , async = require('async') , stats = require('./stats') + , NodeVersion = require('./utils/NodeVersion') ; log4js.replaceConsole(); @@ -39,6 +40,11 @@ var settings var npm = require("npm/lib/npm.js"); async.waterfall([ + function(callback) + { + NodeVersion.enforceMinNodeVersion('6.9.0', callback); + }, + // load npm function(callback) { npm.load({}, function(er) { diff --git a/src/node/utils/NodeVersion.js b/src/node/utils/NodeVersion.js new file mode 100644 index 00000000..bee58f02 --- /dev/null +++ b/src/node/utils/NodeVersion.js @@ -0,0 +1,37 @@ +/** + * Checks related to Node runtime version + */ + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Quits if Etherpad is not running on a given minimum Node version + * + * @param {String} minNodeVersion Minimum required Node version + * @param {Function} callback Standard callback function + */ +exports.enforceMinNodeVersion = function(minNodeVersion, callback) { + const semver = require('semver'); + const currentNodeVersion = process.version; + + // we cannot use template literals, since we still do not know if we are + // running under Node >= 4.0 + if (semver.lt(currentNodeVersion, minNodeVersion)) { + console.error('Running Etherpad on Node ' + currentNodeVersion + ' is not supported. Please upgrade at least to Node ' + minNodeVersion); + } else { + console.debug('Running on Node ' + currentNodeVersion + ' (minimum required Node version: ' + minNodeVersion + ')'); + callback(); + } +}; diff --git a/src/package.json b/src/package.json index 5968ce15..e3ce3444 100644 --- a/src/package.json +++ b/src/package.json @@ -67,8 +67,8 @@ "wd": "1.6.1" }, "engines": { - "node": ">=0.10.0", - "npm": ">=1.0" + "node": ">=6.9.0", + "npm": ">=3.10.8" }, "repository": { "type": "git",