Changing package managers doesn't remove your npm registry dependency

By

npm is both a command and a package registry. Learn what switching to pnpm or Bun changes, and how caches, lockfiles, and mirrors affect failed installs.

~~~

You can replace npm install with another command and still download your packages from the same server.

That distinction gets lost whenever an installation fails and someone recommends switching package managers. Sometimes that fixes the problem. Sometimes the new command makes the same request and fails too.

Let’s look at where the dependency lives, and what to check before changing your toolchain.

npm means two things

The npm CLI is the program you run in your terminal. It reads the project, resolves dependencies, and installs packages.

The npm registry is a service that stores package metadata and package archives. The public registry lives at registry.npmjs.org. The CLI’s registry documentation explains how the client chooses a registry.

Other clients can use that service. A different dependency layout on your disk doesn’t imply a different source for those dependencies.

Fig 1 · 1/4Which part of the install changed?
npm fetches from the public registry

The figure shows the difference. Replacing the client changes the first box. A warm cache can satisfy a request locally. A separate registry or proxy changes the network path.

Find which part failed

Imagine a deployment that stops while installing dependencies. Before replacing npm with pnpm, read the first useful error.

A package archive returning a server error suggests a different problem from an unsupported Node version. A package’s install script can fail after the archive has downloaded successfully. Authentication can also fail for a private package while public packages remain available.

Write down the package name and the URL in the error, if there is one. Compare the Node and package-manager versions in the working and failing environments. Check whether the failure happens before or after package scripts start.

For an npm project, this command prints the configured default registry:

npm config get registry

Also inspect the project’s .npmrc. A scope such as @acme can use a different registry from the default. Take care when sharing configuration because authentication settings may be nearby.

These checks tell you whether changing the client addresses the failure you have.

Keep the lockfile

A lockfile records the dependency tree you agreed to install. Deleting it during an outage adds another variable: the next install can resolve different dependency versions.

For automated npm installs, use npm ci. It requires a lockfile and fails when it disagrees with package.json, instead of quietly updating it. It also removes an existing node_modules before installing.

npm ci

A committed lockfile makes the install more repeatable. The package archives still have to come from somewhere. A fresh build machine needs access to the required bytes, even when every version is pinned.

The package-lock.json documentation describes the resolved locations and integrity information recorded for packages.

A cache only helps with packages it has

A local cache can save downloads and make repeated builds faster. A successful cached build is useful evidence that the application still builds. It doesn’t prove a clean machine can fetch every dependency.

npm describes its cache as self-healing, and explicitly advises against treating it as a reliable permanent package store.

During an incident, avoid clearing a working cache as a reflex. You can remove the very files that let the machine continue building.

For a deployment pipeline, distinguish a package-download cache from an old node_modules directory. Cache keys should account for the environment and lockfile. Restoring dependencies built for another platform can create a new failure unrelated to the registry.

When a proxy helps

A caching registry proxy can keep copies of packages your team already fetched. Your clients request packages through it, and the proxy retrieves missing ones upstream.

Its usefulness during an outage depends on what it has stored. A new dependency can still require the public registry. You also take responsibility for running the proxy, controlling access, and retaining its data.

Before adopting one, test the failure you care about. Start a clean build with upstream access disabled. Does it complete using only the packages you intended to retain?

For a small project, a committed lockfile and a sensible CI cache may be enough. For a business whose releases depend on installing packages at any moment, test recovery on a clean runner. That gives you a concrete answer about what your build can survive.

Want me to talk about your product? You can sponsor this site.