Script that checks the current Node version. Useful in the preinstall script of a project's package.json.
'use strict';
(() => {
let message = '';
let exitCode = 0;
let supportedNodeVersion = 'v4.3.0';
if (process.version === supportedNodeVersion) {
message = 'You are using the supported Node version for this project. Continuing...';
} else {
message = `Node ${supportedNodeVersion} is required for this project. Exiting...`;
exitCode = 1;
}
console.log(message);
process.exit(exitCode);
})();