Skip to content

fix: bypass packument cache to prevent ETARGET errors after publish#9045

Merged
wraithgar merged 1 commit intonpm:latestfrom
Jadu07:fix/pack-cache-bypass
Mar 2, 2026
Merged

fix: bypass packument cache to prevent ETARGET errors after publish#9045
wraithgar merged 1 commit intonpm:latestfrom
Jadu07:fix/pack-cache-bypass

Conversation

@Jadu07
Copy link
Contributor

@Jadu07 Jadu07 commented Mar 1, 2026

This PR fixes a bug where running npm pack <package-spec> immediately following npm publish in the same environment (like a GitHub Actions workflow) results in an ETARGET error ("No matching version found").

When npm publish runs, the remote registry updates, but any previous registry requests may cause pacote to cache the older packument locally. When npm pack runs right after, it reads that stale local cache which lacks the newly published version, skipping the remote fetch entirely.

To fix this, I've added preferOnline: true to the fetch configurations in lib/commands/pack.js (specifically to the pacote.manifest() and libpack() calls). This ensures npm pack passes a cache: 'no-cache' configuration down to the registry fetcher, forcing an online re-validation that bypasses the local max-age cache and successfully locates the newly published tarball. This aligns pack's cache behavior with npm view.

References

Fixes #9043

@Jadu07 Jadu07 requested a review from a team as a code owner March 1, 2026 08:34
@wraithgar wraithgar self-assigned this Mar 2, 2026
@wraithgar wraithgar merged commit 6565eeb into npm:latest Mar 2, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] After npm publish, npm pack cannot find the package

2 participants