microsoft/playwright · error · Error

Only one of --dry-run and --list can be specified

Error message

Only one of --dry-run and --list can be specified

What it means

Thrown by `playwright install` when both --dry-run (print what would be downloaded without installing) and --list (list available/executable browsers) are passed. Each flag is a different non-mutating inspection mode; combining them produces contradictory output, hence the guard `options.dryRun && options.list`.

Source

Thrown at packages/playwright-core/src/cli/installActions.ts:120

      `    npx playwright install`,
      ``,
      `If your project does not yet depend on Playwright, first install the`,
      `applicable npm package (most commonly @playwright/test), and`,
      `then run Playwright's install command to download the browsers:`,
      ``,
      `    npm install @playwright/test`,
      `    npx playwright install`,
      ``,
    ].join('\n'), 1));
  }
  if (options.shell === false && options.onlyShell)
    throw new Error(`Only one of --no-shell and --only-shell can be specified`);
  const shell = options.shell === false ? 'no' : options.onlyShell ? 'only' : undefined;
  const executables = registry.resolveBrowsers(args, { shell });
  if (options.withDeps)
    await registry.installDeps(executables, !!options.dryRun);
  if (options.dryRun && options.list)
    throw new Error(`Only one of --dry-run and --list can be specified`);
  if (options.dryRun) {
    for (const executable of executables) {
      console.log(registry.calculateDownloadTitle(executable));
      console.log(`  Install location:    ${executable.directory ?? '<system>'}`);
      if (executable.downloadURLs?.length) {
        const [url, ...fallbacks] = executable.downloadURLs;
        console.log(`  Download url:        ${url}`);
        for (let i = 0; i < fallbacks.length; ++i)
          console.log(`  Download fallback ${i + 1}: ${fallbacks[i]}`);
      }
      console.log(``);
    }
  } else if (options.list) {
    const browsers = await registry.listInstalledBrowsers();
    printGroupedByPlaywrightVersion(browsers);
  } else {
    await registry.install(executables, { force: options.force });
    await registry.validateHostRequirementsForExecutablesIfNeeded(executables, process.env.PW_LANG_NAME || 'javascript').catch((e: Error) => {

View on GitHub (pinned to c8fc3bf8d3)

Solutions

  1. Use --dry-run alone to preview downloads: `npx playwright install --dry-run`.
  2. Use --list alone to enumerate installed browsers: `npx playwright install --list`.
  3. Remove the redundant flag from CI scripts or aliases.

Example fix

// before
npx playwright install --dry-run --list
// after
npx playwright install --list
Defensive patterns

Strategy: validation

Validate before calling

if (args.includes('--dry-run') && args.includes('--list'))
  throw new Error('Choose one inspection mode: --dry-run OR --list');

Prevention

When it happens

Trigger: Running `npx playwright install --dry-run --list` or a script that appends both inspection flags. The error fires after executables are resolved but before either print branch runs.

Common situations: CI debugging scripts that bolt on flags incrementally; aliases that set --list by default while a developer adds --dry-run to test downloads.

Related errors


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