Skip to content
Discussion options

You must be logged in to vote

You need to add a restore-keys option to help GitHub Actions find a matching cache.

Here’s an updated version of your step:

- name: Cache node modules
  uses: actions/cache@v4
  with:
    path: node_modules
    key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
    restore-keys: |
      ${{ runner.os }}-node-

This way, if the exact hash isn’t found, GitHub Actions will try to use a partial match.

Also, make sure your package-lock.json file is checked into the repository — without it, the cache won’t work.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@codexmith75
Comment options

Answer selected by codexmith75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Question Ask and answer questions about GitHub features and usage Misc General discussions about GitHub Actions that don't fit other found themes.
2 participants