What you see
Cache not found for input keys: Linux-node-3f2a9c..., Linux-node-Common causes
- The lockfile changed, so the key changed, which is expected.
- The entry was evicted because the repository went over its cache storage limit or the entry was not used for a while.
- The job runs on a branch that cannot read caches from other branches except the default branch.
- A key built from a file path that does not exist, so hashFiles returns an empty string.
How to fix it
- 01
Add restore-keys
A prefix match restores the newest similar cache when the exact key misses.
.github/workflows/ci.yml - uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- - 02
Check the key inputs
Print the hash to make sure the file pattern matches something.
.github/workflows/ci.yml - run: echo "${{ hashFiles('**/package-lock.json') }}" - 03
Make misses cheap
When the cache misses, dependencies are downloaded. A registry cache in your region turns that into a fast, local download.
.npmrc registry=https://acme.cacheport.cc/npm/