Node.js Version Utility

4.3.0 · active · verified Sun Apr 19

node-version is a lightweight JavaScript utility designed to parse the current Node.js runtime version (from `process.version`) into a structured object. It provides granular access to major, minor, and patch segments, alongside powerful helper methods for semantic version comparison, such as `isAtLeast`, `isAbove`, `isBelow`, and `isAtMost`. The package, currently at stable version 4.3.0, maintains an active release cadence with minor and patch updates introducing features like `eolDate` and `daysUntilEOL`. Key differentiators include its pure ESM architecture (since v4), full TypeScript support, and built-in checks for Node.js Long Term Support (LTS) status and End-of-Life (EOL) dates, making it an ideal choice for modern Node.js applications that require robust version management and awareness.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates importing the `version` object and accessing its parsed properties and helper methods, including LTS/EOL checks. Also shows `getVersion()`.

import { version, getVersion } from 'node-version';

// Access the pre-instantiated version object
console.log('Current Node.js version:', version.long);
console.log('Is LTS?', version.isLTS);
if (version.isLTS) {
  console.log('LTS Name:', version.ltsName);
}
console.log('Is EOL?', version.isEOL);
if (version.isEOL) {
    console.log('End-of-Life Date:', version.eolDate);
    console.log('Days until EOL:', version.daysUntilEOL);
}

// Perform version comparisons
if (version.isAtLeast('20.0.0')) {
  console.log('Running on Node.js 20 or newer.');
} else {
  console.log('Running on an older Node.js version.');
}

if (version.isAbove('22.0.0')) {
  console.log('Running on Node.js strictly above 22.0.0.');
}

// Get a new NodeVersion instance
const specificVersion = getVersion();
console.log('Another instance (same info):', specificVersion.original);

view raw JSON →