Determine most popular version of a given npm pack

2019-03-26 04:37发布

问题:

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.

回答1:

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



回答2:

It'd be really nice if there are such statistics provided by NPM. But unfortunately there aren't any such statistics available at the moment.

NPM only provides total downloads in the last month. If you want to see total downloads over a larger period of time you can use npm-stat. But also it doesn't give download status specific to each version.

Usually npm install --save <package-name> installs the latest version available at the moment, which is locked to the package.json file. If u want to upgrade to the advanced version later, currently the best way is to follow the upgrade instruction provided by the package's documentation or seek support from the developers of the package to check if the upgrade is worth your time.