Skip to content
Discussion options

You must be logged in to vote

I faced this exact issue a few weeks ago. Here are the most common reasons and fixes:

  1. Check if cache is actually being restored

First, look at your workflow logs. Do you see Cache restored from key or Cache not found? If it says Cache not found, your key isn't matching.

Fix: Make sure package-lock.json exists and is being committed. If it's missing, hashFiles('**/package-lock.json') returns empty and cache misses every time.

  1. Don't cache node_modules directly

The official docs actually recommend against caching node_modules. It can cause issues with Node version mismatches and npm ci.

Better approach: Cache ~/.npm instead:

- name: Cache npm dependencies
  uses: actions/cache@v4
  with:…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by zaidonly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug GitHub or a GitHub feature is not working as intended Code Security Build security into your GitHub workflow with features to keep your codebase secure Welcome 🎉 Used to greet and highlight first-time discussion participants. Welcome to the community! source:ui Discussions created via Community GitHub templates Code Quality Code Quality helps users improve code reliability, maintainability, and overall project health
2 participants