node-version-check

Check if the version of Node is greater than or equal to some version

MIT 9 个版本
安装
npm install node-version-check
yarn add node-version-check
pnpm add node-version-check
bun add node-version-check
README

node-version-check

Check if the runtime Node version satisfies some version

NPM Version Windows Build Status Code Coverage

Greenkeeper badge Dependency Status Dev Dependency Status

Usage

This module is meant to help out with running things only if the runtime version of node is greater than or equal a given version, such as 4.

The module exposes a binary called node-version-check, which takes a string to check against as an argument.

Example usage is for example to not run eslint>=3 on version of node less than 4.

"scripts": {
  "lint": "node-version-check \">=4\" && eslint . || node-version-check \"<4\""
}

It uses node-semver's satisfies under the hood, this allows you to check against any arbitrary version, such as exact (node-version-check '4.0.0') or minor (node-version-check '^4.0.0') etc..

Extra binaries

For convenience, a binary to check whether the node version is >=4 and <4 is also included.

"scripts": {
  "lint": "node-version-gte-4 && eslint . || echo Node version too old to run linting"
}

A bin with lt is also included to avoid having to handle the OR case.

"scripts": {
  "lint": "node-version-gte-4 && eslint . || node-version-lt-4"
}

There are also binaries for node@>=6 and node@<6 included.

版本列表
2.2.0 2017-07-09
2.1.1 2016-08-20
2.1.0 2016-07-29
2.0.2 2016-07-08
2.0.1 2016-07-08
2.0.0 2016-07-08
1.1.0 2016-07-08
1.0.1 2016-07-04
1.0.0 2016-07-04