@kurone-kito/nodejs-versions-list

Since getting a list of Node.js version numbers is tedious, we'll periodically convert the contents of the official dist into JSON.

Usage no npm install needed!

<script type="module">
  import kuroneKitoNodejsVersionsList from 'https://cdn.skypack.dev/@kurone-kito/nodejs-versions-list';
</script>

README

🟨 @kurone-kito/nodejs-versions-list: JSON of Node.js versions list

Getting a list of Node.js versions can sometimes be a pain. Typically, you can parse the official dist to get it, but you may want to get the version number more easily.

There is also a handy library for this purpose, all-node-versions.

The @kurone-kito/nodejs-versions-list library pre-parses the results of his library into JSON so that you can get a list of versions of this package at the time you installed it.

System requirements

  • Node.js >= 14.17

Usage

First, you should install this package in your project.

npm install @kurone-kito/nodejs-versions-list
yarn add @kurone-kito/nodejs-versions-list

And, that’s all!

import list from '@kurone-kito/nodejs-versions-list';

console.log(JSON.stringify(list.versions));
console.log(JSON.stringify(list.majors));

Since the body is JSON, you need to specify the resolveJsonModule flag if you want to use it in your TypeScript project.

See the all-node-versions package’s document for the JSON structure.

The type definition of JSON
interface AllNodeVersionsReturns {
  /**
   * List of Node.js major releases sorted from the most to the
   * least recent. Each major release has the following properties.
   */
  majors: {
    /**
     * Latest version for that major release,
     * as a `major.minor.patch` string.
     */
    latest: string;
    /**
     * LTS name, lowercased. `undefined` if the major release is not LTS.
     */
    lts?: string;
    /** Major version number. `0` for old releases `0.*.*`. */
    major: number;
  }[];
  /**
   * List of available Node.js versions sorted from the most to the
   * least recent. Each version is a `major.minor.patch` string.
   */
  versions: string[];
}
The developer documentation for this library can be found here.

Install the dependencies

npm ci

Linting

npm run lint

Build

npm run prepack

License

MIT