A daemon to sync packages across npm registries.
npm-registry-sync
is a daemon (background process) that synchronizes packages across multiple npm registries.
It's useful in scenarios where there are multiple private npm registries (eg. Enterprise Artifactory) with different packages.
For example, given two private npm registries A & B, where A is currently reachable but B is not (eg. behind firewall), npm-registry-sync
will download all versions of the specified packages from A. When B is finally reachable, it will publish all versions of the specified package to registry B.
-
Setup a directory with a configuration file:
npm-registry-sync.config.json
:{ "registries": { "registry-id-a": { "name": "Registry name A", "url": "https://registry-url-a/", "npmrc": "~/npmrc/file", // (Optional) "strictSSL": false, // (Optional) // These packages will be downloaded and published to the other registries "packages": [ "package-name-a", "package-name-b", "package-name-c", // .... ] }, "registry-id-b": { "url": "https://registry-url-b/", // ... }, // ... }, // Registry polling interval in seconds "pollingInterval": 60 }
Tip: Use npmrc to manage configurations for multiple npm registries.
You can then reference the appropriate configuration in
~/.npmrcs/
. -
Make sure npm is authenticated to the registries:
npm whoami --registry <registry url>
-
Start
npm-registry-sync
:npx npm-registry-sync
Or run it in the background using screen:
screen npx npm-registry-sync
export type Config = {
registries: Record<string, {
// Name of the registry (used for logging)
name: string
// URL of the registry
url: string
// Optional `.npmrc` file
// Compatible with https://www.npmjs.com/package/npmrc
npmrc?: string
// Whether to disable SSL when interacting with registry
strictSSL?: boolean
// Array of package names to download
// and publish to other registries
packages?: string[]
}>
// Frequency to poll the registries in seconds
// Default: 60
pollingInterval: number
}