Yura Yura -4 years ago 155
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

library of specific version e.g. obtain dependency tree of library
of version

Now, I would like to use HTTP requests for this as much as possible instead of launching
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
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download