Registry / devops / node-version

node-version

JSON →
library4.3.0jsnpmunverified

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.

devopstesting
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The 'node-version' package is ESM-only since v4.0.0. Using `require()` will result in an `ERR_REQUIRE_ESM` error.

import { version } from 'node-version';

This function returns a new `NodeVersion` object instance for the current process, distinct from the pre-instantiated `version` export. It also requires ESM `import`.

import { getVersion } from 'node-version';

This is a TypeScript type import for type-checking purposes, not a runtime value. It is only relevant in TypeScript projects.

import type { NodeVersion } from 'node-version';

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);
Debug
Known footguns
breakingStarting with v4.0.0, the `node-version` package is exclusively pure ES Module (ESM). CommonJS support has been entirely removed.
breakingVersion 4.0.0 and above explicitly require Node.js runtime version 20.0.0 or higher, as specified in the `engines` field.
gotchaAttempting to use `require()` to import `node-version` in a CommonJS context will lead to an `ERR_REQUIRE_ESM` error.
deprecatedFor applications requiring CommonJS support, version 3.x.x is the last major release that supports `require()`. All subsequent major versions are ESM-only.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
10 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
googlebot
1
Resources