简体   繁体   中英

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 在 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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM