Registry / devops / node-semvers

node-semvers

JSON →
library1.7.2jsnpmunverified

Resolves individual and ranges for versions of Node.js by version numbers, codenames, and expressions. Current version: 1.7.2 (stable, infrequent releases). Supports semver ranges, LTS aliases, and codename lookups. Similar to nave but with semver expression support. Ships TypeScript types.

npm install node-semvers
INSTALL
IMPORT
SIG · NODE-SEMVERS
N
node-semvers
devopsjavascriptv1.7.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

default
import NodeVersions from 'node-semvers'
const { NodeVersions } = require('node-semvers')
The library exports a class (constructor function) as default. CommonJS require returns the class directly, not an object.
NodeVersions
import NodeVersions from 'node-semvers'
import { NodeSemvers } from 'node-semvers'
The default export is the class. No named exports exist.
load
const instance = await NodeVersions.load()
const instance = new NodeVersions.load()
load() is a static method on the class. It returns an instance after loading version data.
resolve
instance.resolve('lts')
NodeVersions.resolve('lts')
resolve is an instance method, not static. You must call load() first and then resolve on the returned instance.

Demonstrates loading node versions, resolving LTS alias, semver range, and codename lookup.

import NodeVersions from 'node-semvers'; const semvers = await NodeVersions.load(); // Resolve latest LTS const lts = semvers.resolve('lts'); console.log('LTS:', lts); // Resolve a range const rangeVersions = semvers.resolve('10.0.0 || ~12.0.0'); console.log('Range:', rangeVersions); // Resolve by codename const argon = semvers.resolve('lts/argon'); console.log('Argon LTS:', argon);
Debug
Known issues
gotchaload() is asynchronous and must be awaited. Calling resolve on an unloaded instance will fail.
fix
Use await or a callback when calling load.
affects: >=1.0.0
gotcharesolve returns a string for specific expressions (e.g., 'lts'), but an array of strings for range expressions (e.g., '10.0.0 || ~12.0.0'). Mismatching handling can cause unexpected behavior.
fix
Check the return type: typeof result === 'string' ? [result] : result for uniform array handling.
affects: >=1.0.0
breakingVersion lookup data is fetched from external sources at runtime. Network issues may cause load() to fail or return stale data.
fix
Consider caching the fetched data locally or handling network errors.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: NodeVersions.load is not a function
Using named import or destructured require incorrectly.
fix
Use default import: import NodeVersions from 'node-semvers'
TypeError: semvers.resolve is not a function
Calling resolve on the class instead of an instance, or not awaiting load.
fix
Use const semvers = await NodeVersions.load(); then semvers.resolve(...)
Cannot read property 'versions' of undefined
load() failed due to network error or invalid mocked data.
fix
Check network connectivity or provide a valid data source.
Upgrade
Version history
1.7.2latest on npm
Audit
Dependencies
semverrequiredUsed for parsing and comparing semver ranges. Listed as a dependency in package.json.
Agent activity
2 hits · last 30 days
node
2
Resources
node-semvers — npm install node-semvers · libregistry