wanted-node-version

1.0.1 • Public • Published

wanted-node-version

Detects which version of Node your program should be using, by looking at .nvmrc, .node-version and the engines.node field of package.json.

Installation

npm install wanted-node-version --save

Usage

const wantedNodeVersion = require('wanted-node-version');
 
const versionInfo = wantedNodeVersion(process.cwd());
 
console.log(versionInfo);

Outputs:

{ sources:
   { '.nvmrc': '8',
     '.node-version': '9.0.0',
     'engines.node': '>=8' },
  version: '8',
  conflict: true }
  • The sources property is an object that contains the version-range that was set for each source.
  • The version property is a string containing the wanted node version-version from the first of nvmrc, node-version, engines.node (in that order).
  • The conflict property tells you if all version ranges found are in conflict (true) or not (false).

See also

To further deal with version-range strings, I recommend using the excellent semver module.

License

MIT

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i wanted-node-version

    Weekly Downloads

    20

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    11.4 kB

    Total Files

    8

    Last publish

    Collaborators

    • ronkorving