Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I know the minimum node.js version for my project?

Does NPM have a command to list the minimum Node version dependency based on the available project modules?

like image 495
Miguel Q. Avatar asked Sep 19 '14 10:09

Miguel Q.


People also ask

How do I know what version of node a project needs?

To verify the node version per JavaScript project, I found this npm package check-node-version. It allows you to verify the node version via CLI (Command Line Interface) or programmatically. I used both ways, just because I had two projects with different requirements.

How do I select node js version?

The n command for installing and activating a version of Node is simple: n 6.17. 1 . You could also use n latest for the latest version of Node or n lts for the latest LTS version of Node. If the version of Node is already installed, then n will simply switch to that version.

Which version of Nodejs should I use?

Nodejs org makes new versions frequently with new features, bug fixes, and performance optimizations. As a general rule, we can safely assume that the latest version is always the best version to use. A major node version increments the first number like this: 6. x.x, 7.

How do I set node version in project?

Use the engines keyword in the package. json file to specify the Node. js version that you want your application to use. You can also specify a version range using npm notation.


2 Answers

No. There is no built-in way to recursively check the current package and its dependencies and collate the engines.node requirement into a cohesive whole.

If you are on a unix-like system you can try this command:

find . -name package.json | xargs grep -h node\": | sort | uniq -c

It will give you something like this output:

    1     "gnode": "0.1.0",
    36     "node": "*"
    1     "node": "0.10.x || 0.8.x"
    1     "node": "0.4 || >=0.5.8"
    1     "node": ">= 0.10.0"
    3     "node": ">= 0.4"
    3     "node": ">= 0.4.0"
    2     "node": ">= 0.4.1 < 0.5.0"
    2     "node": ">= 0.6"
    1     "node": ">= 0.6.6"
    8     "node": ">= 0.8"
    3     "node": ">= 0.8.0"
    1     "node": ">=0.1.90"
    2     "node": ">=0.10.0"
    5     "node": ">=0.4"
    9     "node": ">=0.4.0"
    3     "node": ">=0.4.12"
    3     "node": ">=0.4.9"
    5     "node": ">=0.6"
    5     "node": ">=0.8"
    19     "node": ">=0.8.0"
    1     "node": ">=0.8.x"
    1   "engines": { "node": ">= 0.4.0" }
    1   , "dnode": "10.999.14234"

Where (in addition to some extraneous 'gnode' and 'dnode') you can see that the minimum version for some dependencies is '0.10', but many dependencies claim to work with all versions of node ('*').

To see which package.json requires which version, use this:

find . -name package.json | xargs grep node\":
like image 81
Sam Mikes Avatar answered Oct 17 '22 21:10

Sam Mikes


You can use the ls-engines package.

https://www.npmjs.com/package/ls-engines

> ls-engines
`package.json` found; building the ideal tree from package.json...

Valid node version range: ^14 || ^13 || ^12 || ^11 || ^10 || ^9 || ^8 || ^7 || ^6 || ^5 || ^4 || ^0.12 || ^0.11 || ^0.10 || ^0.9 || ^0.8

Currently available, most recent, valid node major versions: v14.2, v13.14, v12.16.3, v11.15, v10.20.1, v9.11.2, v8.17, v7.10.1, v6.17.1, v5.12, v4.9.1, v0.12.18, v0.11.16, v0.10.48, v0.9.12, v0.8.28

Current node version, v13.7.0, is valid!
like image 27
Amin Avatar answered Oct 17 '22 20:10

Amin