How to Run Puppeteer in CI Without Chromium Errors
Puppeteer downloads a Chromium build, but Chromium itself needs a long list of shared libraries that slim CI images do not ship.
Puppeteer installs a matching Chromium into its cache. Launch failures in CI are almost always missing system libraries or sandbox restrictions, not Puppeteer itself.
Why it fails in CI
- Chromium dependencies (libnss3, libatk, libgbm, fonts) are missing → "Failed to launch the browser process".
- The Chromium sandbox cannot start in a container without
--no-sandbox. PUPPETEER_SKIP_DOWNLOADwas set, so no browser is present.
Install and run it reliably
Install the Chromium system libraries, let Puppeteer download its browser, and launch headless with the sandbox flags appropriate for CI.
Terminal
# Debian/Ubuntu Chromium deps
apt-get update && apt-get install -y \
libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
libxkbcommon0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 \
libpango-1.0-0 libasound2 libxshmfence1 fonts-liberation
npm ci # puppeteer downloads its ChromiumCache & speed
Cache the Puppeteer browser cache so Chromium is not re-downloaded every run. Key on the Puppeteer version. Chromium launches are flaky; faster managed runners and auto-retry of transient launch failures reduce noise.
.github/workflows/ci.yml
- uses: actions/cache@v4
with:
path: ~/.cache/puppeteer
key: puppeteer-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}Common errors
error while loading shared libraries: libnss3.so→ install the Chromium deps above.No usable sandbox!→ add--no-sandboxin containerized CI.Could not find Chromium→PUPPETEER_SKIP_DOWNLOADwas set, or the cache path is wrong.
Key takeaways
- Chromium needs libnss3/libgbm/fonts and friends - install them in slim images.
- Use
--no-sandboxin containers, judiciously. - Cache
~/.cache/puppeteerkeyed on the Puppeteer version.
Related guides
How to Run Playwright (Node) Tests in CIRun Playwright Node tests in CI: install browsers with system deps, cache the browser binaries, run headless,…
How to Install Headless Chromium in CIInstall headless Chromium in CI: add the shared libraries it needs, choose distro Chromium vs a managed downl…
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…
Self-Healing CI: Missing System Packages and Setup GapsA missing system library or tool fails the build until someone installs it. See the manual fix and how self-h…