Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I determine the most popular version of a given npm package?

The npm registry provides metrics on the most depended packages, but say you wanted to determine the most popular version of a given package - is that possible?

As a user, say I'm thinking of upgrading to react-router^4.0.0, but would like to look at some adoption numbers (i.e. the number of folks running ^3.0.0 vs ^4.0.0), is there a way to do this? Generically, say a given package has 500k downloads in the past month, I couldn't imagine they are all for foobar@latest, so looking at a breakdown of downloads per version would seem to be useful.

Moreover, as a publisher, say I have some packages published to npm and would like to understand which versions of these packages are the most popular with my users. Does npm offer some type of report for this? I can't seem to find these number when I'm logged in and viewing my published items.

like image 244
lux Avatar asked Apr 14 '17 06:04

lux


People also ask

How do I get a specific version of an npm package?

For npm install specific version, use npm install [package-name]@[version-number]. Use npm view [package-name] version to know the specific latest version of a package available on the npm registry. Use npm list [package-name] to know the specific latest version of an installed package.

Which commands is used to find the version of npm?

To check the version of globally installed npm packages, run the npm list command with the -g or --global option added.


2 Answers

NPM exposes now a number of downloads per version.

https://www.npmjs.com/package/typescript -> click "versions"

like image 129
Krzysztof Kaczor Avatar answered Sep 20 '22 21:09

Krzysztof Kaczor


This might not be the answer you are looking for but unfortunately it doesn't seem like that's possible. You do have a way to see total downloads and there are sites like npm-stat to show a breakdown of when downloads are happening. You might be able to infer from when releases happen for specific packages to get an idea of how many downloads that version has.

It's worth mentioning npm's article on how download counts work though so you can't say download counts == number of people who did npm install

Another, although rather extreme, option is you could try and search for JSON files that have the react-router and see the dependencies. I was hoping to see if Github or SearchCode had filtering options for you to specify it but it only has so many filters. You could probably automate this though but naturally it would still not be very accurate.

Also worth mentioning there is an open issue regarding instrumenting analytics into npm CLI

like image 36
aug Avatar answered Sep 16 '22 21:09

aug