Created
October 29, 2019 03:44
-
-
Save coffeesam/fd345e56891492cf8da6190a465014fa to your computer and use it in GitHub Desktop.
Check Node Version from package.json file vs runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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