Skip to content

The npm read-through cache puts a package registry proxy close to your Nx Agents. The first time a package is requested, it is fetched from the public npm registry and stored in the cache. Repeated installs of the same package are then served from the cache instead of the upstream registry, cutting install time and external network usage. Once the cache is warm, packages often install faster than restoring them from node_modules caching.

It also protects your organization from npm registry outages.

You can enable npm read-through cache through your organization settings:

  1. Open Settings > Add-ons for your organization.
  2. Under Dedicated compute cluster card, find npm read-through cache and click Request add-on and confirm.

When the add-on is enabled, Nx Cloud runs a caching proxy in your dedicated cluster that sits in front of the public npm registry. You point your package manager at the proxy through an .npmrc file. Installs then flow through the cache.

The cache works with npm, yarn, and pnpm, since they all read the registry setting from .npmrc.

  • Public npm packages only. The cache proxies the public npm registry.
  • Private and scoped packages that require authentication are not cached. Keep their existing registry entries in your .npmrc. Those requests bypass the cache and go straight to your private registry.

Point your package manager at the cache by setting the registry in an .npmrc. Place it in the project root (simplest) or in the agent's home directory (~/.npmrc):

.npmrc
registry=http://npm:4873/

The cache is always reachable from within your cluster at the address above.