Skip to content
Latchkey

npm Cache ENOENT on a Cached Tarball - Fix Corrupted _cacache in CI

npm’s content-addressable cache (_cacache) stores tarballs by integrity hash. A partially-restored CI cache or an interrupted write can leave an index entry whose content file is missing, so npm fails reading from its own cache rather than from the network.

What this error means

npm ci/npm install fails with an ENOENT for a path under _cacache, or an integrity error reading a cached tarball - even with the registry reachable. It typically follows a restored CI cache or a cancelled previous install. A clean cache fixes it.

npm output
npm error code ENOENT
npm error syscall open
npm error path /home/runner/.npm/_cacache/content-v2/sha512/ab/cd/...
npm error errno -2
npm error Error: ENOENT: no such file or directory, open '.../_cacache/...'

Common causes

A partially-restored or interrupted cache

A restored CI cache that was uploaded mid-write, or an install killed partway, leaves _cacache with index entries pointing at content files that are not present.

A corrupted content-addressable entry

A damaged cache entry fails the integrity/existence check, so npm errors reading its own store instead of fetching fresh.

How to fix it

Verify or clean the cache and refetch

Repair the cache (or force-clear it) so the missing/corrupt entry is re-fetched.

Terminal
npm cache verify
# if that does not clear it:
npm cache clean --force
rm -rf node_modules
npm ci

Avoid restoring a partial cache

  1. Key the npm cache on the lockfile and only save it on successful installs.
  2. Do not restore a cache from a cancelled/failed job.
  3. Raise fetch-retries so a single refetch self-recovers.

How to prevent it

  • Save the npm cache only on successful runs.
  • Bust the cache key when _cacache errors appear.
  • Run npm cache verify in flaky-cache pipelines.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →