What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To run Puppeteer on AWS CodeBuild, select a Linux build image that matches your browser, install the project dependencies and a Puppeteer-compatible browser in the build environment, ensure the browser’s Linux shared libraries are available, and run your tests from a CodeBuild buildspec. Puppeteer normally manages a compatible browser download; if your package manager blocks install scripts, install the browser explicitly. A custom image gives you more control over the browser and its dependencies, while a CodeBuild-managed image may be simpler if its operating system and tools suit your project.

The example below is a starting point, not a tested CodeBuild project. Browser versions, image inventories, and Linux dependencies change, so verify the chosen combination in your own build logs.

What CodeBuild needs to run Puppeteer

CodeBuild runs your commands inside a selected Docker image and compute environment. That image determines the operating system, architecture, installed tools, and libraries available to the browser. AWS supports its own curated CodeBuild images as well as custom images, including accessible public Docker Hub and Amazon ECR images. AWS recommends CodeBuild repository images for service optimization, but that does not make one image universally right for every Puppeteer workload.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a reliable setup, treat these as separate requirements:

  • Node.js and your project: the build environment must support the version and package manager your project uses.
  • A browser Puppeteer can launch: normally Puppeteer downloads a compatible Chrome for Testing and headless shell.
  • Browser system libraries: a browser binary can still fail to start if its Linux shared-library dependencies are absent.
  • Repeatable build commands: put dependency installation, browser setup when needed, and tests in the buildspec.

Choose the image and architecture before writing browser-specific setup. A local machine and CodeBuild can differ in operating system, architecture, installed libraries, package-manager policy, and browser cache location; any one of these differences can explain a build that works locally but fails in CodeBuild.

Choose a managed image or a custom Docker image

Consideration CodeBuild-managed image Custom image
OS and architecture Choose an available image that matches your project and intended browser. Select and maintain the base image and architecture yourself.
Browser and library setup Install what is missing during the build, if the image supports your setup. Package a known browser and its dependencies into the image, or install them during the build.
Version control Keep Puppeteer’s managed browser aligned with the installed Puppeteer version. Maintain the browser binary and any explicit executable path alongside the image.
Maintenance responsibility Depends on the selected image and your build-time setup. You are responsible for rebuilding and maintaining the image contents.
Build startup and Docker use Validate startup and resource behavior for your workload; no universal comparison is established. Validate startup and resource behavior for your workload. Privileged mode is relevant if the build itself needs Docker, not merely because it launches Chrome.

A custom image can make browser and library versions more explicit, but it also makes image maintenance your responsibility. A managed image can reduce image-building work, but you still need to check that its OS, architecture, and available libraries fit the browser you intend to launch. AWS documents both approaches; workload-specific testing is needed to decide between them.

If you use a custom image, do not make build setup depend on its Docker ENTRYPOINT: AWS says CodeBuild overrides custom image entrypoints. Put setup in the buildspec instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Puppeteer and its browser

When you install the puppeteer package normally, its installation process downloads a compatible Chrome for Testing and headless shell. Some package-manager policies block install scripts. In that case, the package may be present while its browser is missing, so a later launch fails with a missing-browser error.

There are two usual approaches:

  • Allow Puppeteer’s install hook: use your package manager’s approved policy to permit the Puppeteer install script, then verify the browser download in the CodeBuild logs.
  • Install the browser explicitly: run npx puppeteer browsers install in the build environment that will run the tests.

Do not assume a browser downloaded on a developer workstation is available in CodeBuild. The browser must be installed in the build environment, and its files must be accessible at the cache location Puppeteer uses there.

If the project uses puppeteer-core, manage the browser binary yourself and configure Puppeteer through its API. puppeteer-core does not apply Puppeteer configuration files or environment variables. If you supply a different Chrome or Chromium binary, set executablePath to its actual path. Otherwise, Puppeteer normally selects its managed browser.

Install the browser’s Linux dependencies

Having a Chrome executable is not sufficient if the selected image lacks shared libraries that Chrome needs. This is particularly important with a custom Linux image. Determine the dependencies for your specific base image and browser version, then validate the result in CodeBuild. The Puppeteer troubleshooting documentation includes a Docker example using Node 14; treat it as an old illustration, not a current Dockerfile recipe to copy unchanged.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When a browser starts and immediately exits, or logs a missing-library message, inspect the build output and check the selected image’s dependencies. Add the required libraries to the custom image or install them as part of setup where appropriate. The exact dependency list depends on the chosen OS image and browser; do not assume one package list works across all Linux images.

Configure the buildspec

CodeBuild uses a YAML buildspec, which defaults to buildspec.yml in the source root. Version 0.2 keeps commands in the same shell instance. This outline installs Node dependencies, explicitly installs Puppeteer’s browser, and runs the project’s test command:

version: 0.2
phases:
  install:
    commands:
      - npm ci
      - npx puppeteer browsers install
  build:
    commands:
      - npm test

Save it as buildspec.yml at the repository root unless your CodeBuild project is configured to use a different buildspec path. Replace npm ci or npm test if your project uses another package manager or test script. If Puppeteer’s install hook is permitted and reliably downloads the browser, the explicit browser-install command may be unnecessary. If the browser is preinstalled in a custom image, omit that download only after confirming Puppeteer launches the intended binary.

To make the project’s browser launch explicit when it uses a non-default binary, configure it in the test code. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const puppeteer = require('puppeteer');

async function main() {
  const browser = await puppeteer.launch({
    executablePath: process.env.CHROME_PATH,
    headless: true
  });

  try {
    const page = await browser.newPage();
    await page.goto('https://example.com', { waitUntil: 'networkidle0' });
    console.log(await page.title());
  } finally {
    await browser.close();
  }
}

main().catch(error => {
  console.error(error);
  process.exitCode = 1;
});

Use that explicit path only if you set CHROME_PATH to the real executable path in the CodeBuild environment. If it is unset or points to the wrong file, the launch will fail; for Puppeteer’s managed browser, leave out executablePath and let Puppeteer select its browser. This example demonstrates browser launch structure, not a claim that a particular Chrome path exists in a CodeBuild image.

Keep environment values and permissions deliberate

CodeBuild environment values replace existing values rather than shell-expanding them. Do not set PATH to a literal value such as $PATH:/some/bin expecting the shell to expand it; use the project’s actual environment configuration without overwriting the required search path.

For environment-variable precedence, CodeBuild applies start-build overrides first, then project-level values, then buildspec values. Keep credentials and other secrets out of plaintext buildspec values: AWS recommends parameter-store or Secrets Manager mappings.

Do not enable privileged mode just to launch Puppeteer. Privileged mode is for Docker daemon interaction and Docker image builds. If the build itself builds Docker images, follow CodeBuild’s Docker daemon and VPC guidance for that separate requirement.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run and validate the first build

  1. Confirm the source configuration: check that buildspec.yml is at the source root, or verify the project’s configured buildspec path.
  2. Check the install phase: confirm the project dependencies install and, when required, that the browser-install command completes in the build environment.
  3. Check browser launch: run the Puppeteer test and inspect logs for missing-browser, executable-path, or shared-library errors.
  4. Check test behavior: confirm the expected page or test result, and ensure the test closes the browser even when an error occurs.
  5. Repeat the build: compare later logs when changing the image, package manager, browser, or library setup. Keep the selected image and browser arrangement intentional rather than relying on a workstation-only cache.

No specific CodeBuild compute size, memory threshold, or maintained image/browser pairing is established here. Browser-heavy test suites should be validated with the actual workload and CodeBuild environment rather than assigned a universal resource recommendation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common Puppeteer failures

“Could not find Chrome” or missing browser

Likely cause: the install hook was blocked, the browser was never installed in CodeBuild, or Puppeteer is looking in a different cache location from the one populated during setup.

Fix: inspect the install logs, permit the package install hook under your package-manager policy or run npx puppeteer browsers install, and ensure installation and tests run in the same build environment. For a preinstalled browser, set executablePath to its verified location.

Chrome exits immediately or reports a missing library

Likely cause: the selected image does not contain a shared library required by the browser.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: identify the dependency missing from the logs and provide it in the chosen image. Re-check dependencies if you change the base image or browser version; do not copy an old example’s package list without validating it against the current environment.

The browser version is incompatible

Likely cause: Puppeteer and the browser binary are not aligned, or an unintended system browser is being launched.

Fix: prefer Puppeteer’s managed compatible browser, or explicitly point to the intended browser with executablePath and maintain a compatible version pairing.

It works locally but fails in CodeBuild

Likely causes to investigate:

  • The local and CodeBuild operating systems or architectures differ.
  • CodeBuild lacks a browser library present on the workstation.
  • The package manager blocks install scripts in the build.
  • The browser cache differs or is not available in the environment running the tests.

Compare the actual build environment and logs rather than assuming any one difference is responsible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An environment setting changes unexpectedly

Likely cause: a buildspec or project environment value replaces an existing value, or a start-build override takes precedence.

Fix: check the three precedence levels—start-build override, project, then buildspec—and avoid assigning literal $PATH text. Put secrets in supported secret stores rather than plaintext environment variables.

Or skip the browser setup

If your goal is to capture a website screenshot rather than run browser automation or tests, ScreenshotNeo provides a screenshot API. One GET request can return a PNG, JPEG, WebP, or PDF. Its capture process accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses include X-Page-Verdict and X-Billed headers. ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents.

For example, save this as capture.sh, replace the URL as needed, and set your API key:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options and response details. If you need Puppeteer to click through an application, run assertions, or exercise browser behavior, keep the CodeBuild setup above; a screenshot API is not a substitute for those tests.

ScreenshotNeo offers 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000, and every feature is available on every plan. Sign up for free ScreenshotNeo screenshots.

Frequently Asked Questions

Does Puppeteer require privileged mode in CodeBuild?

No. Launching Chrome is distinct from building Docker images; privileged mode is relevant when the build needs Docker daemon interaction.

Can I use puppeteer-core with a browser already in my image?

Yes, but you manage the browser binary and configure it through the Puppeteer API; puppeteer-core does not apply Puppeteer configuration files or environment variables.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is there a universal CodeBuild memory size for Puppeteer?

No universal size or memory threshold is established for Puppeteer here. Validate the actual test workload in the chosen CodeBuild environment.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.