How to Cache and Install the Cypress Binary in CI
Cypress installs an npm package and, separately, a large platform binary. Caching only node_modules loses the binary and re-downloads it every run.
The Cypress binary lives in ~/.cache/Cypress, not node_modules. Treating it as a distinct cache is the key to fast, reliable Cypress installs in CI.
Why it fails in CI
- The binary download from the Cypress CDN times out or is rate-limited.
- Only node_modules was cached, so the binary re-downloads each run.
- A version bump leaves a cached binary that no longer matches the package.
Install it reliably
Install the package, cache the binary directory keyed on the Cypress version, and verify the binary before running tests. Pin the version for cache stability.
Terminal
npm ci # installs the cypress package
npx cypress install # ensures the binary is present
npx cypress verify # validates it before tests
# point the cache elsewhere if needed:
export CYPRESS_CACHE_FOLDER="$PWD/.cache/Cypress"Cache & speed
Cache ~/.cache/Cypress keyed on the lockfile (which pins the version). The download is a known flaky step; auto-retry of transient failures and larger managed runners reduce lost time.
.github/workflows/ci.yml
- uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}Common errors
The Cypress App could not be downloaded→ transient CDN issue; retry or mirror the binary.Cypress verification timed out→ restore the binary cache or raiseCYPRESS_VERIFY_TIMEOUT.- Re-downloads every run → you cached node_modules but not
~/.cache/Cypress.
Key takeaways
- The Cypress binary lives in
~/.cache/Cypress, separate from node_modules. - Cache that directory keyed on the pinned version.
- Run
cypress verifyto catch a bad binary before the suite.
Related guides
How to Run Cypress in CI Without Verification FailuresRun Cypress in CI: install the binary, add Linux dependencies, cache ~/.cache/Cypress, run headless, and fix…
How to Install Playwright Browsers in CIInstall Playwright browser binaries in CI: use install --with-deps, cache by version, install only the browse…
How to Install Headless Chromium in CIInstall headless Chromium in CI: add the shared libraries it needs, choose distro Chromium vs a managed downl…
Self-Healing CI: Auto-Retrying Transient Registry and 5xx FailuresRegistry timeouts, 429s, and 5xx errors are transient by definition. See why they happen and how self-healing…