puppeteer/puppeteer · error

Could not resolve the current platform

Error message

Could not resolve the current platform

What it means

Thrown by `#install` when `args.platform` is falsy after yargs parsing. The platform option defaults to `detectBrowserPlatform()`, which returns `undefined` on operating systems Node does not map to darwin/linux/win32. This is the install-command counterpart to the platform detection failure.

Source

Thrown at packages/browsers/src/CLI.ts:626

  }

  #resolvePinnedBrowserIfNeeded(buildId: string, browserName: Browser): string {
    if (buildId === 'pinned') {
      const options = this.#pinnedBrowsers?.[browserName];
      if (!options || !options.buildId) {
        throw new Error(`No pinned version found for ${browserName}`);
      }
      return options.buildId;
    }
    return buildId;
  }

  async #install(args: InstallArgs) {
    if (!args.browser) {
      throw new Error(`No browser arg provided`);
    }
    if (!args.platform) {
      throw new Error(`Could not resolve the current platform`);
    }
    args.browser.buildId = this.#resolvePinnedBrowserIfNeeded(
      args.browser.buildId,
      args.browser.name,
    );
    const originalBuildId = args.browser.buildId;
    args.browser.buildId = await resolveBuildId(
      args.browser.name,
      args.platform,
      args.browser.buildId,
    );
    await install({
      browser: args.browser.name,
      buildId: args.browser.buildId,
      platform: args.platform,
      cacheDir: args.path ?? this.#cachePath,
      downloadProgressCallback: 'default',
      baseUrl: args.baseUrl,

View on GitHub (pinned to d484e21c17)

Solutions

  1. Pass `--platform <value>` explicitly with one of: linux, linux_arm, mac, mac_arm, win32, win64.
  2. Run on a supported OS image (Linux/macOS/Windows).
  3. Confirm detection with `node -e "const d=require('@puppeteer/browsers/detectPlatform'); console.log(d.detectBrowserPlatform())"`.

Example fix

// before
npx @puppeteer/browsers install chrome
// after (on an undetected host)
npx @puppeteer/browsers install chrome --platform linux
Defensive patterns

Strategy: validation

Validate before calling

import { detectBrowserPlatform, BrowserPlatform } from '@puppeteer/browsers';
const platform = detectBrowserPlatform();
if (!platform) {
  throw new Error(`Auto-detection failed on ${process.platform}; pass --platform <value>`);
}

Type guard

import { BrowserPlatform } from '@puppeteer/browsers';
function isSupportedPlatform(): boolean {
  return detectBrowserPlatform() !== undefined;
}

Prevention

When it happens

Trigger: Running `install` on an OS where `detectBrowserPlatform()` returns `undefined` and no explicit `--platform` is supplied.

Common situations: Exotic or unsupported host OS in CI (e.g. a FreeBSD jail), a misreported `os.platform()`, or a stripped-down container environment.

Related errors


AI-assisted analysis of puppeteer/puppeteer@d484e21c17 (2026-08-12). Data as JSON: /api/errors/7b94c79daaad2ae9. Report an issue: GitHub.