Interview Prep/GitHub Actions/Caching, Artifacts, Runners & ARC

Why cache the package manager's download cache rather than `node_modules`?

AdvancedConceptCaching, Artifacts, Runners & ARC
Answer

npm ci deletes node_modules before installing, so a cached node_modules is wasted; and node_modules contains platform-specific native builds that break across OS or Node versions. Caching ~/.npm keeps downloads local while npm ci still gives a clean, lockfile-exact install. The exception is very large monorepos where install time itself dominates; then cache node_modules keyed on OS, Node version and lockfile hash, and skip npm ci on an exact hit.

All GitHub Actions questions Roadmap: GitHub Actions

More on Caching, Artifacts, Runners & ARC