ScreenshotNeo

BlogHow-to

How to Check If Playwright Is Installed

Check Playwright from the correct project environment, verify browser binaries separately, and fix version, path, dependency, and executable errors.

By the ScreenshotNeo team29 September 20268 min read

How to Check If Playwright Is Installed

To check whether Playwright is installed in a Node.js project, open a terminal in the project directory and run the command that matches your package manager:

npx playwright --version
# or
yarn playwright --version
# or
pnpm exec playwright --version

If the command prints a version, the Playwright CLI resolves from that project context. That confirms the package is available to the command, but it does not prove that the required browser binaries are installed. Playwright’s package and its browser executables are separate installation conditions.

Check browser binaries with:

npx playwright install --list

If the required browser is missing, install it from the same project:

npx playwright install
# Or install only Chromium:
npx playwright install chromium

This distinction explains most “Playwright is installed, but the browser executable is missing” errors.

What each check proves

Check What it proves What it does not prove
playwright --version The package manager can resolve a Playwright CLI and report its version. That a browser binary exists, or that your application uses the same environment.
playwright install --list Which Playwright browser installations are visible to the current installation and environment. That every browser your tests request is installed, or that system libraries are present.
Cache inspection Where browser files may be stored. That the active process can read that location.
A launch test That the selected browser can start in the current runtime. That every project, worker, container, or operating system has the same setup.

Playwright browser revisions are coupled to the Playwright package version. Updating the package can require downloading browser revisions again. The official browser documentation summarizes this relationship: each Playwright version needs specific browser binary versions to operate.

A Playwright package version and its browser binaries are separate checks.
A Playwright package version and its browser binaries are separate checks.

Check Playwright in a Node.js project

1. Start in the project directory

Change into the directory containing package.json and the project lockfile. Running a command elsewhere can resolve a different dependency or a global executable.

cd path/to/your-project
ls package.json

Use the package manager indicated by the lockfile:

  • package-lock.json: npx playwright --version
  • yarn.lock: yarn playwright --version
  • pnpm-lock.yaml: pnpm exec playwright --version

2. Check the package version

npx playwright --version

A result such as Version 1.x.y means the command resolved Playwright. The exact version is useful when comparing a local machine, CI runner, and container.

3. Identify the installed package

Projects commonly use either the browser automation package or Playwright Test. Inspect the manifest:

node -e "const p=require('./package.json'); console.log({playwright:p.dependencies?.playwright, devDependency:p.devDependencies?.playwright, test:p.devDependencies?.['@playwright/test']})"

If neither package appears, install the one that matches your code. For Playwright Test:

npm install -D @playwright/test
npx playwright install

For the library API:

npm install playwright
npx playwright install

Do not assume that a globally installed command is the dependency used by your application. Keep the package in the project manifest and use the project package manager in scripts and CI.

4. List browser binaries

npx playwright install --list

The output identifies browser names and revisions known to Playwright. If your code launches Chromium, verify Chromium specifically. If it launches Firefox or WebKit, those binaries must be present too.

5. Install the missing browser

npx playwright install chromium
# Or install the default browser set:
npx playwright install

On supported Linux environments, install operating-system dependencies together with the browser:

npx playwright install --with-deps chromium

The --with-deps option addresses missing system libraries as well as downloading the browser. It may require administrator privileges in your environment.

Python: check the active environment

Python projects must use the same virtual environment for installation, checking, and execution. Activate the environment first:

python -m venv .venv
# macOS/Linux
source .venv/bin/activate
# Windows PowerShell
.venv\Scripts\Activate.ps1

Install the Python package and browsers:

python -m pip install playwright
python -m playwright install

Use the module form to make the interpreter explicit:

python -m playwright install --list

Then run a small launch check:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://example.com")
    print(page.title())
    browser.close()

If python -m playwright works but your application fails, compare the Python executable used by both processes:

python -c "import sys; print(sys.executable)"
python -c "import playwright; print(playwright.__file__)"

.NET: use the generated Playwright script

.NET projects do not use the Node.js npx command as their primary check. After building the project, use the Playwright script generated in the build output. The exact framework directory depends on the project:

dotnet build
pwsh bin/Debug/netX/playwright.ps1 install --list

Replace netX with the target framework directory produced by your build, such as net8.0. To install browsers:

pwsh bin/Debug/netX/playwright.ps1 install

Run the script from the project whose package generated it. A script from another build output can point at a different Playwright version or browser cache.

Browser cache paths and PLAYWRIGHT_BROWSERS_PATH

When the package is present but browsers are reported missing, inspect the browser cache context. Common default locations are:

  • Windows: %USERPROFILE%\AppData\Local\ms-playwright
  • macOS: ~/Library/Caches/ms-playwright
  • Linux: ~/.cache/ms-playwright

The PLAYWRIGHT_BROWSERS_PATH environment variable overrides the location. This is useful for a shared machine or hermetic project-local installation, but every process must use the same value.

# Linux/macOS: inspect the active setting
printf '%s\n' "$PLAYWRIGHT_BROWSERS_PATH"
# PowerShell
$env:PLAYWRIGHT_BROWSERS_PATH

A common failure pattern is downloading browsers with one path and running tests with another. Print the variable in both installation and test steps, then run install --list in the failing process environment.

CI, containers, and deployment checks

  1. Install dependencies with the lockfile, not an unconstrained global package.
  2. Run the project’s Playwright install command during image or job setup.
  3. Cache the browser directory only when the cache key includes the Playwright package version and operating system.
  4. Run install --list in the same container or runner that executes tests.
  5. On Linux, include required system dependencies with --with-deps or the image’s documented dependency step.

For a quick Node.js launch check in CI:

node -e "const { chromium } = require('playwright'); (async()=>{ const b=await chromium.launch({headless:true}); console.log('browser launched'); await b.close(); })().catch(e=>{ console.error(e); process.exit(1) })"

This catches missing executables and shared-library problems earlier than a long test suite.

Troubleshooting common errors

“playwright: command not found”

Cause: Playwright is not installed in the current project, or you invoked a binary outside the package manager context.

Fix: Run npx playwright --version from the directory containing package.json. If it still fails, inspect dependencies and install @playwright/test or playwright as appropriate.

“Cannot find module ‘playwright’”

Cause: Your code imports the library package, but only another package or no package is installed.

Fix: Install the package your import requires, then run the browser installation command. Keep the dependency in the manifest used by deployment.

“Executable doesn’t exist” or “Please run playwright install”

Cause: The CLI package exists, but its version-specific browser binary is absent or inaccessible.

Fix: Run npx playwright install --list, then install the required browser. If it appears installed, compare PLAYWRIGHT_BROWSERS_PATH, user accounts, container layers, and package versions.

The version command works but tests fail after an upgrade

Cause: The package was upgraded without downloading its corresponding browser revision.

Fix: Run the install command again after every Playwright upgrade and invalidate a browser cache keyed to the old version.

Browser launches locally but fails in Linux CI

Cause: Required operating-system libraries, sandbox permissions, or fonts are unavailable.

Fix: Use npx playwright install --with-deps chromium where supported, or add the dependencies required by your base image. Keep the CI user and cache path consistent.

Python reports a different installation than the application

Cause: The install command ran outside the active virtual environment.

Fix: Activate the environment and use python -m playwright install. Print sys.executable from the setup and runtime steps.

.NET cannot find the Playwright script

Cause: The project has not been built, or the framework path is wrong.

Fix: Run dotnet build, inspect bin/Debug, and invoke the generated script under the actual target framework directory.

Performance, reliability, and cost considerations

Checking a version is nearly instantaneous; downloading browsers is the expensive setup step. In CI, cache browser downloads by operating system and Playwright version, but always rerun install --list after dependency changes. A stale cache can be worse than no cache when it hides a revision mismatch.

For reliable automation, pin dependencies with a lockfile, use the same package manager in local development and CI, and make browser installation an explicit setup step. Treat the package version, browser revision, operating-system libraries, cache path, and runtime user as one installation unit.

If your actual goal is producing screenshots rather than maintaining a browser runtime, a hosted capture API can remove browser installation and cache management from your application.

Or skip the browser setup

ScreenshotNeo returns a website screenshot or PDF from one GET request, so your service does not need to install Playwright or browser binaries. See the ScreenshotNeo API documentation for all options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://playwright.dev -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://playwright.dev"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://playwright.dev' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

FAQ

Does a Playwright version prove Chromium is installed?

No. Run playwright install --list and install the required browser separately.

A hosted capture service can remove browser setup and clean pages before capture.
A hosted capture service can remove browser setup and clean pages before capture.

Should I install Playwright globally?

Use the project dependency and its package manager. This keeps the CLI, browser revision, and application version aligned.

Why did an upgrade break a previously working test?

The new package may require different browser binaries. Run the matching install command again and refresh versioned CI caches.

Can I use one browser cache for several projects?

Yes, if the processes share the same PLAYWRIGHT_BROWSERS_PATH and the cache contains the revisions required by each project. Verify with install --list.

What is the fastest check in a Docker build?

After installing the project dependency, run npx playwright install --with-deps chromium, then launch Chromium once in a short smoke check.