Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine NPM package's source url from npmjs.org's registry?

Is there a way to determine a NPM package's source repository URL? Looking at the https://registry.npmjs.org API it doesn't point to the source for the package?

Am trying to figure out how to work back from a dependent package to the source for it - possibly in some automated way. Anyone have any insight they can share?

For example the npmjs.org page for react:

React's package at NPM

Clearly shows the "Repository" link. But the "registry" doesn't include this information. I want to get that Github url to https://github.com/facebook/react from the API/CouchDB database.

UPDATE: Have discovered that the "package" API does indeed provide data I am looking for.

curl https://replicate.npmjs.com/react | jq

Returns:

...
"repository": {
    "type": "git",
    "url": "git+https://github.com/facebook/react.git",
    "directory": "packages/react"
  }
...

But curl https://replicate.npmjs.com/_all_docs\?include_docs\=true -o npm.full.json doesn't include that info.

like image 347
Kit Plummer Avatar asked Oct 19 '25 03:10

Kit Plummer


1 Answers

The answer is that API that provides this info is the package directly:

curl https://replicate.npmjs.com/react | jq
like image 175
Kit Plummer Avatar answered Oct 21 '25 16:10

Kit Plummer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!