
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
node-version
Advanced tools
A lightweight utility to get the current Node.js version parsed into a structured object.
is(), isAtLeast(), isAbove(), isBelow(), isAtMost() checks.# Using npm
npm install node-version
# Using Yarn
yarn add node-version
# Using pnpm
pnpm add node-version
# Using Bun
bun add node-version
import { version } from 'node-version';
console.log(version);
/*
{
original: 'v20.10.0', // same as process.version
short: '20.10',
long: '20.10.0',
major: '20',
minor: '10',
build: '0',
isAtLeast: [Function],
isAbove: [Function],
isBelow: [Function],
isAtMost: [Function],
is: [Function],
isLTS: true, // or false
ltsName: 'Iron', // or undefined
isEOL: false // or true
}
*/
versionThe pre-instantiated version object for the current process.
getVersion()Returns a new NodeVersion object representing the current process version.
import { getVersion } from 'node-version';
const v = getVersion();
NodeVersion Object| Property | Type | Description |
|---|---|---|
original | string | The version string prefixed with 'v' (e.g., 'v20.10.0'). |
short | string | The major and minor version (e.g., '20.10'). |
long | string | The full version string (e.g., '20.10.0'). |
major | string | The major version number. |
minor | string | The minor version number. |
build | string | The build/patch version number. |
isAtLeast(version) | (v: string) => boolean | Checks if the current version is ≥ the specified version. |
isAbove(version) | (v: string) => boolean | Checks if the current version is > the specified version. |
isBelow(version) | (v: string) => boolean | Checks if the current version is < the specified version. |
isAtMost(version) | (v: string) => boolean | Checks if the current version is ≤ the specified version. |
is(version) | (v: string) => boolean | Checks if the current version is exactly the specified version. |
isLTS | boolean | true if the current version is an LTS release. |
ltsName | string | The LTS codename (e.g., 'Iron') or undefined. |
isEOL | boolean | true if the current version is past its End-of-Life date. |
import { version } from 'node-version';
if (version.isAtLeast('20.0.0')) {
console.log('Running on Node.js 20 or newer');
}
if (version.is('22.0.0')) {
console.log('Running on exactly Node.js 22.0.0');
}
if (version.isAbove('20.0.0')) {
console.log('Running on Node.js strictly above 20.0.0');
}
if (version.isBelow('22.0.0')) {
console.log('Running on Node.js strictly below 22.0.0');
}
This package is ESM-only and requires Node.js 20+.
If you need CommonJS support, use node-version@3:
npm install node-version@3
bun run build: Build the project using tsdown.bun run test: Run tests using vitest.bun run lint: Run linting checks using biome.bun run format: Format the code using biome.bun run check-exports: Verify package exports are correct.This project uses Changesets for versioning and publishing.
# Prepare a new version (updates changelog and package.json)
bun run changeset:version
# Publish to NPM
bun run changeset:release
MIT
FAQs
Get Node current version
The npm package node-version receives a total of 214,865 weekly downloads. As such, node-version popularity was classified as popular.
We found that node-version demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.