Guides · Checked on 28 November 2026
How do I cache pnpm in GitHub Actions?
Cache the pnpm store and keep the install step. setup-node caches package data rather than node_modules; pnpm still has to build the workspace from the lockfile.
Restore the pnpm store before installing
Commit
pnpm-lock.yamland pin the pnpm version your project uses. Follow pnpm’s CI guidance for the install. Restore packages only from a cache you trust.Install pnpm before
setup-nodelooks up the store path. Use the lockfile path for the cache key and runpnpm install --frozen-lockfile.
Tested on 28 November 2026
On checklane-2vcpu, setup-node restored the pnpm store. The frozen install completed and the Node test passed. This small fixture verifies the restore, not how much time a larger repository will save.
Show the workflow YAML
name: Reuse the pnpm store
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
install:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: checklane-2vcpu
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '24.22.3'
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
- run: pnpm test
Compare the whole install on a cold run and a warm run of the same commit. Include restore and save time. pnpm cautions that caching the store doesn’t always make CI faster.
On our own CI, a warm pnpm install took a median of 4 s across 343 PR jobs over eight days (20–28 November 2026 UTC). We timed the install step in GitHub’s jobs API and counted successful installs where the setup-node log confirmed a restored pnpm store, excluding copied rerun results.
Related guide: How do I speed up GitHub Actions?
Frequently asked questions
What if pnpm-lock.yaml lives in a subdirectory?
Set cache to pnpm and point setup-node’s cache-dependency-path at the lockfile, for example frontend/pnpm-lock.yaml. The cache key then follows that file rather than looking in the repository root.
actions/setup-node: caching package dataWhy does Turbo report a cache hit when my dist folder is missing?
Check the build task’s outputs in turbo.json. Turborepo can replay the log on a cache hit, but it only restores files you declared as outputs, such as dist/**.
Turborepo: task outputsDoes Vercel Remote Cache need a long-lived token in GitHub Actions?
You can use OpenID Connect instead. Configure an OIDC policy on your Vercel team, give the job id-token: write and run Vercel’s remote-cache setup action with TURBO_TEAM before turbo runs.
Turborepo: remote caching in GitHub ActionsRun this job on Checklane
On Checklane the pnpm store is cached automatically. Keep the install; remove the explicit store cache if both would save the same directory.
Connect your repository, then set the job’s runner label:
runs-on: checklane