npmjs.com

Mirroring the public registry

Sometimes you want your private registry to maintain copies of packages from the public registry. This is called mirroring, and companies do it for a number of reasons:

You can set up different policies to dictate how your npm On-Site server manages mirroring.

NOTE: If you want clients to use the mirrored packages from your npm On-Site server instead of accessing them from the public registry, the clients must be configured to do so.

The default policy for mirroring is the whitelist policy. A whitelist provides a list of packages which should be copied to npm On-Site and periodically updated from the public registry.

The default location for the whitelist is /usr/local/lib/npme/data/whitelist.

You can configure what packages should be copied from the public registry to npm On-Site on the server. Add packages to your whitelist by running this command on the server:

npmo add-package <packagename>

This will trigger mirroring for that package and all of its dependencies.

If you do not want to set up your whitelist manually in advance, you can also configure your server to copy packages to your npm On-Site server (and add them to the whitelist automatically) when they are requested by a client. For example, if a client requested lodash from your npm On-Site server and it did not exist, then npm On-Site would look for lodash in the public registry, copy it over, add it to the whitelist, and then serve it to the client.

To allow clients to add packages to the whitelist, visit npm On-Site's admin console and set Read through cache to Yes.

A full mirror will copy all packages from the public registry to your npm On-Site server. Enable this by setting policy to apply during replication to mirror in npm On-Site's admin console (http://myreg.mycompany.com:8800).

Last modified November 29, 2015           Found a typo? Send a pull request!

Getting Started

How npm works

Private Modules

Organizations

Using npm

npm On-Site

CLI Commands

Configuring npm

npm policy documents

View All On One Page