$ npm i @pkgjs/nv
const nv = require('@pkgjs/nv')
(async () => {
const versions = await nv('lts')
console.log(versions)
/*
[
{
version: '10.16.3',
major: 10,
minor: 16,
patch: 3,
codename: 'dubnium',
versionName: 'v10',
start: 2018-04-24T00:00:00.000Z,
lts: 2018-10-30T00:00:00.000Z,
maintenance: 2020-04-01T00:00:00.000Z,
end: 2021-04-01T00:00:00.000Z
}
]
*/
})()
You can also pass an array of aliases and the resulting array will be sorted and de-duped, for example:
const versions = await nv(['lts', 'maintained'])
console.log(versions.map((v) => v.version))
/*
[ '8.16.1', '10.16.3', '12.11.0' ]
*/
Support Aliases
For now referenced here until we have a more official doc: nodejs/package-maintenance#236 (comment)
all
: All node versionslts_active
: Head of LTS and Active major version lineslts
: Head of current LTS linesactive
: The newest version in the active but not maintenence mode lineslts_latest
/lts/*
: Latest of the LTS lines (lts/*
for nvm compat)maintained
: Head of all maintained linescurrent
: Newest of all maintained lines
Version Aliases
v6
,v8
,v10
,v12
, etc: Head of major version line by version numberdubnium
,carbon
: Named alias for LTS lines