ScreenshotNeo

BlogHow-to

How to Check Whether the Playwright CLI Is Installed

Check Playwright Test, the Agent CLI, and browser binaries separately with the right commands for npm, Yarn, pnpm, and CI.

By the ScreenshotNeo team1 October 20266 min read

Use the command that matches the Playwright tool you mean:

# Playwright Test installed in the current project
npx --no-install playwright --version

# Playwright Agent CLI installed globally
playwright-cli --help

# Playwright Agent CLI installed in the current project
npx playwright cli --help

# Browser binaries installed for Playwright
npx playwright install --list

These checks answer different questions. Playwright Test and the Playwright Agent CLI are separate tools, and a working CLI does not prove that browser binaries are installed.

Which Playwright CLI are you checking?

What you want to verify Command What success means
Project-local Playwright Test npx --no-install playwright --version The project has a locally resolvable Playwright command, without npx downloading a package.
Playwright Test through npm npx playwright --version npx can resolve Playwright. Without --no-install, npx may acquire a package if it is missing.
Playwright Test through Yarn yarn playwright --version Yarn can resolve the project’s Playwright command.
Playwright Test through pnpm pnpm exec playwright --version pnpm can resolve the project’s Playwright command.
Globally installed Agent CLI playwright-cli --help The global @playwright/cli command is on your PATH.
Project-local Agent CLI npx playwright cli --help The local Agent CLI package can be invoked through Playwright’s documented local form.
Downloaded browser executables npx playwright install --list Playwright lists browser binaries available to its installation.

The commands above come from the Playwright installation guide, the Playwright Agent CLI installation guide, and the browser documentation.

Check Playwright Test in an existing project

1. Open the project directory

cd path/to/your-project

Run the check from the directory containing the project’s package.json. Package managers resolve local dependencies from the current project.

2. Check without allowing installation

npx --no-install playwright --version

A version such as 1.x.x means the local Playwright command resolved successfully. If npx reports that it could not find the command, Playwright is not available in that project’s installed dependencies, or dependencies have not been installed yet.

3. Use your package manager’s equivalent

# npm
npx playwright --version

# Yarn
yarn playwright --version

# pnpm
pnpm exec playwright --version

The plain npm form is convenient, but --no-install is the safer diagnostic when you specifically want to know whether the project already has Playwright. The Playwright command-line documentation also shows npx playwright --help for discovering the available Test commands.

4. Inspect the declared dependency

npm ls @playwright/test playwright

# Or inspect package.json directly
node -e "const p=require('./package.json'); console.log({dependencies:p.dependencies, devDependencies:p.devDependencies})"

A declaration in package.json does not guarantee that the package is installed. The version command checks command resolution; npm ls helps reveal missing or invalid installed dependencies.

Check the Playwright Agent CLI

The Agent CLI is a distinct package, @playwright/cli. It is not the same installation path as Playwright Test’s usual @playwright/test package.

Global installation

playwright-cli --help

If the command prints help, the globally installed Agent CLI is available on your PATH. The documented global installation is:

npm install -g @playwright/cli@latest

After installation, open a new terminal if your shell has not refreshed its PATH.

Local installation

npx playwright cli --help

This checks the local-package invocation documented for the Agent CLI. A successful Playwright Test version check does not conclusively prove that this command works, because the tools and package paths differ.

Check whether browser binaries are installed

The Playwright package and its downloaded browser executables are separate. Run:

npx playwright install --list

If the list is empty or does not include the browser you need, install the required binaries:

npx playwright install

In a minimal CI image, you may also need the operating-system dependencies supported by your environment. Keep the package check and browser check separate when diagnosing failures.

Install the right package when a check fails

New Playwright Test project

npm init playwright@latest

The setup wizard creates a Playwright Test project and installs its dependencies. The official setup flow is documented in the installation guide.

Existing project

npm install -D @playwright/test
npx playwright install

Use your project’s package manager consistently. For example, use yarn add -D @playwright/test with Yarn or pnpm add -D @playwright/test with pnpm, then run the corresponding Playwright command.

Agent CLI

# Global
npm install -g @playwright/cli@latest

# Local development dependency
npm install -D @playwright/cli

Useful discovery commands

# Show Playwright Test commands
npx playwright --help

# Show the resolved executable path on Unix-like shells
command -v playwright
command -v playwright-cli

# Show the resolved executable path on Windows PowerShell
Get-Command playwright
Get-Command playwright-cli

# Ask npm where a local package is installed
npm ls @playwright/test @playwright/cli

command -v and Get-Command answer a PATH question. They do not replace the project-local version check, because a globally available command can mask a missing local dependency.

Troubleshooting

Symptom Likely cause Fix
npx --no-install playwright --version cannot find the command Playwright is not installed in the current project, or dependencies are not installed. Run the project’s package-manager install, then repeat the check. Add @playwright/test if it is not declared.
npx playwright --version works, but you are unsure whether it downloaded anything Plain npx is allowed to acquire a package when local resolution fails. Repeat with npx --no-install playwright --version to test local availability only.
playwright-cli is not recognized The Agent CLI is not globally installed or its npm global bin directory is not on PATH. Install @playwright/cli@latest globally, refresh the shell, or use the local form npx playwright cli --help.
Playwright version prints, but a browser will not launch The browser executable is missing or incompatible with the installed package. Run npx playwright install --list, then npx playwright install as needed.
The command works in one directory but not another One project has a local dependency and the other does not, or the shell is resolving a global binary. Run the check beside each project’s package.json and inspect resolution with npm ls and command -v/Get-Command.
CI reports a missing executable after dependency installation CI installed JavaScript packages but did not download Playwright browsers. Add npx playwright install to the CI setup and cache or install browsers according to the environment.
Different versions appear across shells PATH entries or global installations differ between shells or users. Prefer project-local commands, print the resolved command path, and remove stale global assumptions.

CI and scripting checks

For an automated preflight, fail fast when the local Playwright command is absent:

#!/usr/bin/env sh
set -eu

npx --no-install playwright --version
npx playwright install --list

This verifies command resolution and reports browser availability without silently downloading a package during the version check. Keep browser installation in the explicit setup stage so failures are easy to identify.

Or skip the browser setup

If your actual goal is obtaining a screenshot rather than maintaining a Playwright installation, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation for the available options.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed as clean shots, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account.

Performance, reliability, and cost notes

  • A local version check is fast because it resolves installed files; it does not launch a browser.
  • Browser installation is a separate download step, so run it during environment setup rather than inside every test or capture command.
  • Project-local invocations make CI and developer machines more reproducible than relying on an unpinned global command.
  • For screenshot workloads, an API can remove browser download, sandbox, and popup-cleanup work. ScreenshotNeo bills only clean shots and exposes verdict and billing headers so callers can inspect what happened.

FAQ

Is playwright-cli the same as npx playwright?

No. npx playwright is the common Playwright Test invocation. playwright-cli belongs to the separately packaged Playwright Agent CLI.

Does a version output prove that Chromium is installed?

No. Use npx playwright install --list to inspect browser binaries.

Should I use npx playwright --version or --no-install?

Use --no-install when checking whether the current project already has Playwright. Use the ordinary form when you want npx’s normal resolution behavior.

Can I check Playwright without changing the project?

Yes. The --no-install check does not install a package. Browser installation is a separate command and can change the machine’s browser cache.