Skip to content

Instantly share code, notes, and snippets.

@gekkedev
Created July 21, 2024 20:00
Show Gist options
  • Save gekkedev/04e9a8f333ba1e0e70d6dce2ee486910 to your computer and use it in GitHub Desktop.
Save gekkedev/04e9a8f333ba1e0e70d6dce2ee486910 to your computer and use it in GitHub Desktop.
Assert a minimum Node.js version
//asset the right Node.js version for compatibility (see http://node.green)
const requiredMajorVersion = 18
/** extracted major version number from the full version string */
const majorVersion = parseInt(process.version.split(".")[0].replace("v", ""), 10)
if (majorVersion < requiredMajorVersion) {
console.error(
`Node.js version ${process.version} is too low. Please upgrade to version ${requiredMajorVersion} or higher.`
)
process.exit(1)
} else console.log(`Node.js version ${process.version} is sufficient.`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment