Yura Yura - 3 months ago 11
Javascript Question

Get package.json of package using HTTP from public repositories

Maybe this question has already been asked but after a bit of googling I haven't found anything reasonable.

The main goal I'm trying to achieve is to obtain a dependency tree of a specific

npmjs
library of specific version e.g. obtain dependency tree of library
angular
of version
1.5.3


Now, I would like to use HTTP requests for this as much as possible instead of launching
npm
on server-side or using some js library code for that.

What I've found out is:


  1. From http://registry.npmjs.org/package-name one could get all metadata for the specific package as well as list of available versions e.g. http://registry.npmjs.org/angular

  2. From http://registry.npmjs.org/package-name/package-version I could get all metadata for the specific package of specific version e.g. http://registry.npmjs.org/angular/1.5.3



Now, what I'm struggling to find is how to obtain
package.json
of specific library and specific version because http://registry.npmjs.org/angular/1.5.3/package.json doesn't contain anything

Thanks a lot in advance for any hints!

Answer

Ok, it turns that list of dependencies is actually present in file with metadata for the whole package ( located in http://registry.npmjs.org/package-name ).

It's located in versions -> [version-id] -> dependencies, devDependencies and optionalDependencies properties.