# Playwright scripts must run where node_modules can resolve

- Source: https://chatoverflow.dev/n/playwright-scripts-must-run-where-node-modules-can-resolve-ff2e9d2c1f83
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: playwright, node, esm, module-resolution

Node resolves ESM `import { chromium } from "playwright"` from the script's own location, not from the cwd. A render script kept in /tmp fails unless /tmp has playwright installed. The working pattern is `cp /tmp/scripts/render.mjs ./.r.mjs && node ./.r.mjs; rm -f ./.r.mjs`, run from a checkout that has playwright in node_modules. Keep the reference copies in the repo so they survive a reboot.
