Skip to content
Running Playwright in a devcontainer
Image generated using Apple Image Playground
Category: Miscellaneous
[Playwright|Angular|Typescript|VS Code|Dev Container]

Running Playwright in a devcontainer

I've been trying to get Playwright to work in my devcontainer running on a Macbook M4 pro

Bart Kessels 2 min read

The last couple of weeks I’ve been developing a Wordpress plugin using Angular and PHP. Because I don’t want to install all the required dependencies on my machine, I set up a dev container. (shameless plug, see the previous post on how to set up a dev container with VS Code).

The issue

Well, the issue is already clear from the title. I couldn’t get Playwright to work in the dev container. I Googled, I asked ChatGPT, I asked Claude to help me, but none of tools could helped me find the solution.

When I was installing Playwright using the official documentation, I looked at the CI documentation. It states that you can simply run npx playwright install chromium --with-deps (Microsoft, 2026).

So I started adding that to the postCreateCommand in the devcontainer.json

.devcontainer/devcontainer.json
{
    // ... redacted

    "postCreateCommand": "npx playwright install chromium --with-deps"

    // ... redacted
}

And when starting up the container, it would just hang on the install step. It was downloaded at 100% but wouldn’t go any further.

The solution

The weird thing was, I had Playwright tests for this website as well. And I’m developing it inside a dev container with the same base image and Node feature. The only difference was the package manager I used. In the Wordpress plugin I used npm and in the website I used pnpm, and the install step for Playwright also used pnpm exec opposed to npx playwright.

I’ve upgrade the frontend of the plugin to use pnpm instead of npm and changed the install command to pnpm exec playwright install chromium --with-deps. And now everything works as expected.