Skip to content

Instantly share code, notes, and snippets.

@coffeesam
Created October 29, 2019 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coffeesam/fd345e56891492cf8da6190a465014fa to your computer and use it in GitHub Desktop.
Save coffeesam/fd345e56891492cf8da6190a465014fa to your computer and use it in GitHub Desktop.
Check Node Version from package.json file vs runtime
// source: https://stackoverflow.com/questions/29349684/how-can-i-specify-the-required-node-js-version-in-package-json
import semver from 'semver';
import { engines } from './package';
const version = engines.node;
if (!semver.satisfies(process.version, version)) {
console.log(`Required node version ${version} not satisfied with current version ${process.version}.`);
process.exit(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment