node.jsnpmsinopia

How can I get Sinopia to mirror all npm packages from registry.npmjs.org?


I'm working on setting up a complete npm repository in an offline environment, and I'm looking into using Sinopia as the repository.

Apparantly this has been done before. This thread on the Sinopia github page describes a similar scenario, where you download all packages from registry.npmjs.org in an online environment before copying them to the offline environment, and a user even included a script to download all files to the Sinopia backend. The script seems to work, but it doesn't really download all packages - only all versions of packages already installed.

Is there some other way to tell Sinopia to download all pagkages from registry.npmjs.org, or can I somehow get a complete list of packages from registry.npmjs.org and use that to download all files to Sinopia?

Any input is appreciated!


Solution

  • You can use https://skimdb.npmjs.com/registry/_all_docs to get json with the list of all packages in the registry.

    You can use some simple shell script to extract the bare names, e.g.:

    curl -s https://skimdb.npmjs.com/registry/_all_docs | grep \"id\": | cut -d\" -f4
    

    Note: the list used to be available at "registry.npmjs.org/-/short" but it got removed as it was causing big load on the server (as indicated here: https://github.com/npm/npm-registry-couchapp/issues/162)