microsoft/playwright · error · Error

Cannot install ${browserName}

Error message

Cannot install ${browserName}

What it means

Thrown by installBrowsersForNpmInstall (the npm postinstall hook) when a browser name listed in the package's browsers.json 'browsers' array is not found by registry.findExecutable or has installType 'none'. This means the package declares a browser to install at install time that this Playwright build cannot install.

Source

Thrown at packages/playwright-core/src/server/registry/index.ts:1347

      const packageManagerCommand = getPackageManagerExecCommand();
      return `${packageManagerCommand} playwright ${parameters}`;
    }
  }
}

export async function installBrowsersForNpmInstall(browsers: string[]) {
  // PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD should have a value of 0 or 1
  if (getAsBooleanFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD')) {
    logPolitely('Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set');
    return false;
  }
  const executables: Executable[] = [];
  if (process.platform === 'win32')
    executables.push(registry.findExecutable('winldd')!);
  for (const browserName of browsers) {
    const executable = registry.findExecutable(browserName);
    if (!executable || executable.installType === 'none')
      throw new Error(`Cannot install ${browserName}`);
    executables.push(executable);
  }

  await registry.install(executables);
}

// for launchApp -> UI Mode / Trace Viewer
export function findChromiumChannelBestEffort(sdkLanguage: string): string | undefined {
  // Fall back to the stable channels of popular vendors to work out of the box.
  // Null means no installation and no channels found.
  let channel = null;
  for (const name of ['chromium', 'chrome', 'msedge']) {
    try {
      registry.findExecutable(name)!.executablePathOrDie(sdkLanguage);
      channel = name === 'chromium' ? undefined : name;
      break;
    } catch (e) {
    }

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Reinstall the playwright/playwright-core package cleanly to restore a consistent browsers.json.
  2. Set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 to bypass postinstall download, then install browsers explicitly afterward.
  3. Upgrade to a matching Playwright version where browsers.json and the registry agree.
  4. If forked, regenerate browsers.json so every listed name maps to an installable executable.
Defensive patterns

Strategy: fallback

Try / catch

try {
  await installBrowsersForNpmInstall(browsers);
} catch (e) {
  if (/Cannot install/.test(e.message)) {
    console.warn('Postinstall browser install failed; set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 and install manually');
  } else throw e;
}

Prevention

When it happens

Trigger: npm install / yarn install running Playwright's postinstall where browsers.json references a browserName that findExecutable cannot resolve or that is detection-only; typically only happens with a corrupt or mismatched browsers.json or a hand-edited package.

Common situations: A vendored/forked Playwright with an inconsistent browsers.json; a partial publish where browsers.json and registry definitions drifted; an old browsers.json carried over an upgrade.

Related errors


AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12). Data as JSON: /api/errors/323adab5bb685b2e. Report an issue: GitHub.