actions / actions/setup-node

Question: How to properly cache node-gyp builds?

Open
#785 7 comments 1 reaction 1 assignee View on GitHub

@v-gowridurgad is already working on this.

Since Sep 9, 2026.

feature request
Dominant language
TypeScript
Stars
5k
Forks
1.7k
Avg merge
3d 12h
Merged PRs (30d)
2

Description

Hello,

Description:

I'm struggling to figure out how to properly cache node-gyp builds. This adds +30s to my yarn install, by rebuilding them every time yarn install runs.

After manually caching and restoring the build paths, it still triggers a new gyp build every yarn install. The paths I cached:

# Cache location of node headers
~/.cache/node-gyp
# Explicit caching of the affected packages
node_modules/cpu-features/build
node_modules/unix-dgram/build

My previous question in the node-gyp repo lead me here. The suggestion was to look into node-gyp-build.

Any advice would be appreciated.

Justification:

Save myself time and the planet by not wasting electricity.

Are you willing to submit a PR?

Of course.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.