Skip to content

srod/node-version

Repository files navigation

NPM Version NPM Downloads GitHub Actions Codecov

Node-version

A quick module that returns current node version parsed into parts.

Installation

npm install node-version
# Or Yarn
yarn add node-version
# Or pnpm
pnpm add node-version

Quick Start

import { version } from 'node-version';

/*
console.log(version);

{
    original: 'v0.4.10', // same as process.version
    short: '0.4',
    long: '0.4.10',
    major: '0',
    minor: '4',
    build: '10'
}
*/

Warning

Version 4.0.0 (ESM-only)

Starting with v4.0.0, this package is ESM-only and requires Node.js 20+.

// ESM (v4+)
import { version } from 'node-version';

If you need CommonJS support, use v3.x:

npm install node-version@3

Version 1.0.0

Version 1.0.0 break 0.1.0 since its API changes.

Change

var currentVersion = new (require('node-version').version)();

To

var currentVersion = require('node-version');

How to publish

To publish a new version, you can use the following commands:

# For a latest release
bun run publish-latest

# For a beta release
bun run publish-beta

Note: Replace xxx with your OTP in the package.json if needed, or set it via environment variable.

License

MIT

About

Get Node current version

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 11