Skip to content

Instantly share code, notes, and snippets.

@maggiben
Created January 3, 2022 02:01
Show Gist options
  • Save maggiben/0cda51c16f3c1a1d1611556a109ccb51 to your computer and use it in GitHub Desktop.
Save maggiben/0cda51c16f3c1a1d1611556a109ccb51 to your computer and use it in GitHub Desktop.
Get Node Version
export function getNodeVersion(): { major: number; minor: number; patch: number } {
const version = process.version.match(/(\d+)\.(\d+)\.(\d+)/);
const [major, minor, patch] = ensureArray(version)
.slice(1)
.map((match) => parseInt(match as string, 10));
return {
major,
minor,
patch,
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment