Created
July 21, 2024 20:00
-
-
Save gekkedev/04e9a8f333ba1e0e70d6dce2ee486910 to your computer and use it in GitHub Desktop.
Assert a minimum Node.js version
This file contains 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
//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