Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which versions of npm came with which versions of node?

Tags:

node.js

npm

Which versions of npm came with which versions of node? I can't find such a list.

like image 358
Loren Avatar asked Jul 09 '18 05:07

Loren


People also ask

How to install previous versions of node and NPM on Windows?

Installing the previous version of Node.js and NPM: To install the previous versions from the latest version, the latest version of Node.js should be installed on your computer or you can install it from the official site of Node.js. Step 1: Check the installed version of Node and NPM on the computer use the following command respectively

How do I check if Node JS and NPM is installed?

To see if you already have Node.js and npm installed and check the installed version, run the following commands: Node version managers allow you to install and switch between multiple versions of Node.js and npm on your system so you can test your applications on multiple versions of npm to ensure they work for users on different versions.

What is the difference between NPM and Node JS?

However, npm is released more frequently than Node.js, so to install the latest stable version of npm, on the command line, run:

What are node version managers and how do they work?

Node version managers allow you to install and switch between multiple versions of Node.js and npm on your system so you can test your applications on multiple versions of npm to ensure they work for users on different versions.


2 Answers

here is the list :

Node >> 10.6.0 npm >> 6.1.0

node >> 9.0.0 npm >> 5.5.1

https://nodejs.org/en/download/releases/

like image 165
Mihir Kanzariya Avatar answered Sep 19 '22 02:09

Mihir Kanzariya


At https://nodejs.org/dist/ there is index.json which indicates each version of nodejs and which version of npm is bundled with it.


index.json

An excerpt from one of the objects in the array of index.json reads:

[
  {
    "version": "v10.6.0",       //<--- nodejs version
    "date": "2018-07-04",
    "files": [
      ...
    ],
    "npm": "6.1.0",             //<--- npm version
    "v8": "6.7.288.46",
    "uv": "",
    "zlib": "1.2.11",
    "openssl": "1.1.0h",
    "modules": "64",
    "lts": false
  },
  ...
]

Whereby each object in the array has a version (i.e. the nodejs version) and npm (i.e. the npm version) key/value pair.


Programmatically obtaining the versions

Consider utilizing the following node.js script to request the data from the https://nodejs.org/dist/index.json endpoint.

get-versions.js

const { get } = require('https');

const ENDPOINT = 'https://nodejs.org/dist/index.json';


function requestVersionInfo(url) {
  return new Promise((resolve, reject) => {
    get(url, response => {
      let data = '';
      response.on('data', chunk => data += chunk);
      response.on('end', () => resolve(data));
    }).on('error', error => reject(new Error(error)));
  });
}


function extractVersionInfo(json) {
  return JSON.parse(json).map(({ version, npm = null }) => {
    return {
      nodejs: version.replace(/^v/, ''),
      npm
    };
  });
}


(async function logVersionInfo() {
  try {
    const json = await requestVersionInfo(ENDPOINT);
    const versionInfo = extractVersionInfo(json);
    console.log(JSON.stringify(versionInfo, null, 2));

  } catch ({ message }) {
    console.error(message);
  }
})();

Running the following command:

node ./path/to/get-versions.js

will print something like the following to your console:

[
  {
    "nodejs": "14.2.0",
    "npm": "6.14.4"
  },
  {
    "nodejs": "14.1.0",
    "npm": "6.14.4"
  },
  {
    "nodejs": "14.0.0",
    "npm": "6.14.4"
  },
  {
    "nodejs": "13.14.0",
    "npm": "6.14.4"
  },
  ...
]

As you can see it lists each version of nodejs and it's respective version of npm.

like image 41
RobC Avatar answered Sep 21 '22 02:09

RobC