is-node-modern

Detects if node is modern, with helpful command line tools

Usage no npm install needed!

<script type="module">
  import isNodeModern from 'https://cdn.skypack.dev/is-node-modern';
</script>

README

is-node-modern NPM Module

Detects if node is modern, with helpful command line tools

Linux Build MacOS Build Windows Build

Coverage Status Dependency Status bitHound Overall Score

Install

npm install --save-dev is-node-modern

then add to your package.json following script:

  "scripts": {
    "my-action": "is-node-modern && thing-I-want-to-do-in-modern-node-versions || is-node-not-modern"
  }

By default it will consider modern node versions that equal or above LTS version.

Also you can specify custom threshold, like:

  "scripts": {
    "my-action": "is-node-modern 6 && thing-I-want-to-do-in-node-v6-or-above || is-node-not-modern 6"
  }

to execute provided commands within custom threshold.

Example

CLI

Running eslint in node version equal or above 4 (current LTS version):

  "scripts": {
    "lint": "eslint *.js",
    "ci-lint": "is-node-modern && npm run lint || is-node-not-modern"
  }

Now you can have CI for node versions below 4, while running latest eslint only within node@4+.

Node

Also, it could be used as regular node module:

var isNodeModern = require('is-node-modern');

if (isNodeModern())
{
  // only run in node@4+
}

if (isNodeModern(6))
{
  // only run in node@6+
}

License

Is-Node-Modern is released under the MIT license.