All stories

One npm approval, two packages. What if only one publishes?

npm can approve staged releases in one batch, but each package can succeed or fail on its own. Here’s how to spot a partial publish before consumers do.

A vintage two-lane parcel sorter has released a green parcel while another waits behind a metal gate.

Your UI package is live. The Core version it depends on isn’t. You leave the latest tag alone and assume no one will hit the broken release yet. Then someone runs npm install '@example/ui@^2.0.0'.

They can get the new UI. They still can’t get its dependency.

The short version: npm’s new batch approval saves you separate 2FA challenges, but each publish can still succeed or fail on its own. Before you announce a release, check the exact versions in the registry and try a clean install. A dist-tag won’t keep a published stable version out of a matching range.

What one approval buys you

GitHub announced batch approval on 30 November. Staged publishing separates sending a tarball to npm from making it available to consumers. CI can stage the package, and a maintainer can inspect the staged artifact and approve it later. npm’s staged publishing guide describes staging and review from the CLI, and the new batch action on npmjs.com. The batch holds up to 100 versions, with at most one version of any given package. The feature is rolling out gradually, so the control may not be visible on every account yet.

A maintainer can review the version, publisher, dist-tag and checksum for each artifact before confirming. The resulting approval covers that selected set. For a team moving publishing out of a long-lived CI token and into a workflow with human approval, that removes a lot of friction without requiring the person approving to build a fresh artifact on their own laptop.

The limit shows up after confirmation. npm documents a separate outcome for each version. If one fails, successful publishes are not rolled back. Don’t treat the result as all-or-nothing or rely on a particular order in which packages become available.

Two packages, one missing version

Take a fictional workspace with two packages: @example/core and @example/ui. Both are at 1.9.0. The new UI calls an API added in Core 2, so its packed manifest pins @example/core to 2.0.0. An exact dependency makes the example easy to reason about; the same problem arises with any range for which the registry has no matching version.

CI tests the two packages together in the workspace. The tests pass because both source trees are there. The team stages both stable 2.0.0 artifacts under the next dist-tag and selects them in the same batch. After approval, UI succeeds and Core fails. The public registry now has a UI version that asks for something consumers can’t fetch.

Consumer requestWhat happens in this example
npm install @example/uiResolves the older latest version, assuming default npm settings and an empty project.
npm install @example/ui@nextSelects UI 2.0.0; there is no Core 2.0.0 to satisfy its dependency.
npm install '@example/ui@^2.0.0'Can select UI 2.0.0 even though latest still points to 1.9.0.

That last row is easy to miss. A dist-tag points at a version; it doesn’t hide other published versions that match an explicit range. The npm version picker can prefer the default tag if it satisfies the request. For ^2.0.0, 1.9.0 doesn’t satisfy it. A stable 2.0.0 release can be selected under its version even if you haven’t promoted its tag. The exact Core dependency also doesn’t care which tag Core carries. It just needs that version to exist.

A local check with npm’s version picker and synthetic registry metadata reproduced the three version choices above. With only a release candidate under next, ^2.0.0 returned no match. The check didn’t publish packages or run a full install. The missing Core version is part of the fictional example.

Pick the kind of release you actually want

If the packages are ready for stable use, publish dependencies before the packages that need them. In this example, confirm Core 2.0.0 is available before approving UI 2.0.0. You trade a second approval for a dependency check between the two changes. For a bigger dependency graph, you can group packages in waves and keep one approval per wave. It takes longer than one batch, but a failure stops you before you release its dependants. Independent packages are better candidates for the same batch.

If the goal is a candidate release that ordinary stable ranges won’t pick up, assign candidate versions as well as a candidate tag. For example, publish both packages as 2.0.0-rc.1, with UI depending on the matching Core prerelease. Under npm’s SemVer prerelease rules, a normal ^2.0.0 request doesn’t match 2.0.0-rc.1. Someone explicitly installing @next can still hit a partial candidate publish, so the dependency check remains useful. And an RC tests the RC artifacts, not the stable tarballs you will pack and release later.

In either case, inspect the published manifest rather than assuming it matches how the workspace resolves packages. Local links can let your tests import the right code while the tarball declares the wrong dependency or leaves out a built file.

Check the registry like a new consumer

If a batch returns mixed results, start with what exists. The examples below use placeholder package names. Replace them with yours and use the same registry your consumers use.

npm view @example/core@2.0.0 version
npm view @example/ui@2.0.0 dependencies --json
npm dist-tag ls @example/ui

Then make a fresh temporary project outside the workspace, without a lockfile, and install the exact UI version. If you are about to announce a tag, do a second fresh install using that tag. Run a small check that imports and uses the published package. A pinned npm ci in an existing consumer is valuable for reproducibility, but it’s not a check of what a new project resolves today. npm’s install docs explain when an existing lockfile guides resolution.

If approval expired or the result could not be confirmed, refresh and check the current state before starting another batch. If npm offers a Retry button to finalise results, use it to check completion rather than assuming nothing was published. If the missing dependency is correct and can still be approved, release it and repeat the consumer check. If the already-published package declares the wrong dependency, prepare a corrected version; npm doesn’t let you reuse a published name and version.

What to check before announcing

  1. Before approval, write down the versions and tags you intend to ship, plus one consumer check per dependency boundary.
  2. After approval, compare the live versions and tags with that list. If a required version is missing, stop and resolve it before announcing.
  3. Run the checks from a fresh consumer project against the exact version and the tag you’re about to tell people to install.

For the example above, you don’t need a second copy of the workspace tests. A clean project that installs the exact UI version and calls a small API that needs Core 2 is enough to expose a missing dependency or a tarball that can’t load. If you publish for both CommonJS and ESM, use a smoke check for each entry point you claim to support. Keep any candidate test separate from the stable one so a cached install or old lockfile doesn’t accidentally stand in for the release you meant to verify.

Moving next back can help someone installing via that tag, but it doesn’t hide a broken stable version from a range that still matches it. If you publish a corrected version, make clear what consumers pinned to the broken version should install instead.

Use batch approval to save maintainer time. Use a clean consumer install to decide when the release is ready.

Adam Spice

Developer. Curious human.

More stories