简体   繁体   中英

Fetching all private npm modules from an npmjs user

I'm working on a task to migrate all of our npm modules from npmjs.com. Problem is, all of our modules are stored under an npm user as private packages, and I can't find a way to consume all packages the user owns programmatically.

I found many examples that explain how to migrate a single package or a list of packages by name, but I've yet to understand how can I fetch every package a user owns to create that list.

There are a few modules that allow interacting with the NPM registry API, but I couldn't find out how to make them consume private scoped packages. I'm currently working with the npm-registry-fetch to try and get an example query working with no luck.
This is the code I'm trying to run -

var npmFetch = require('npm-registry-fetch')


async function run() {
  var response = await npmFetch.json('@<scope redacted>/<package name redacted>',{token: '<token redacted>'})
}

run()

This code results in this error -
HttpErrorGeneral: 404 Not Found - GET https://registry.npmjs.org/@<scope redacted>/<package name redacted> - Not found

How can I successfully query these type of packages?
Thanks.

Updating that this SO answer gave me the tools I've needed, performing the request as a curl command worked, so I'll just use that instead of using fancy registry clients. Thanks again internet stranger!

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