CircleCI save_cache "path not found" / Empty Cache - Fix
save_cache warns that a path does not exist or stores almost nothing. The directory you listed is wrong, has not been created yet, or the cache step runs before the install that populates it.
What this error means
The job logs "Skipping cache - ... path does not exist" or saves a tiny/empty cache, and the next run still installs from scratch. The cache exists but is useless because it captured the wrong directory.
save_cache
- Skipping the cache: the path /home/circleci/.npm does not exist
# or
- Saving cache (0 B)Common causes
Path does not exist or is wrong
The cache directory differs from where the tool actually writes - e.g. caching node_modules when you should cache ~/.npm, or a path under the wrong home directory for the image user.
save_cache runs before install
If save_cache is placed before the install step, the directory is empty (or absent) when it captures, so nothing useful is stored.
Caching a derived dir instead of the package cache
Caching large build outputs or node_modules directly is fragile; the package manager’s own cache (~/.npm, ~/.cache/pip) restores more reliably.
How to fix it
Cache the right directory, after install
steps:
- checkout
- restore_cache:
keys: [deps-v1-{{ checksum "package-lock.json" }}]
- run: npm ci
- save_cache:
key: deps-v1-{{ checksum "package-lock.json" }}
paths:
- ~/.npmConfirm the real cache location for the image
- Print the package manager cache dir (
npm config get cache,pip cache dir). - Use that absolute path in
save_cache.paths. - Place
save_cacheafter the step that populates the directory.
How to prevent it
- Cache the package manager’s cache dir, not
node_modules. - Always save after install, restore before it.
- Verify the path exists for the image’s user/home.