Skip to content

Conversation

Sascha1707
Copy link
Contributor

On Windows with Node.js 22.x, invoking the @ngx-playwright/test binary fails with:

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]:
Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

Root cause
packages/test/bin.cjs resolves the Playwright CLI to an absolute Windows path and passes it directly to import(). Since Node 22 treats ESM specifiers as URLs, C:... is interpreted as the unsupported scheme c: and is rejected.

Fix
Convert the absolute path to a file:// URL using pathToFileURL(...) before calling import().

Compatibility:

-Works on Node 18/20/22
-Cross-platform (Windows/macOS/Linux)
-No breaking changes

How I tested:
Windows 11
Node.js 22.13.1 (repro), Node.js 20.17.0 (sanity)

npx playwright --version and running tests via the package binary

Notes:
An alternative would be using createRequire(import.meta.url) to require() the CLI, but the file:// approach keeps the current dynamic import() and fixes the ESM URL issue cleanly.

Thanks!

On Windows with Node.js 22.x, invoking the @ngx-playwright/test binary fails with:

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]:
Only URLs with a scheme in: file, data, and node are supported by the default ESM loader.
On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'


Root cause
packages/test/bin.cjs resolves the Playwright CLI to an absolute Windows path and passes it directly to import(). Since Node 22 treats ESM specifiers as URLs, C:\... is interpreted as the unsupported scheme c: and is rejected.

Fix
Convert the absolute path to a file:// URL using pathToFileURL(...) before calling import().
@bgotink bgotink merged commit c001ac5 into bgotink:main Aug 29, 2025
@bgotink
Copy link
Owner

bgotink commented Aug 29, 2025

Thanks! I hardly ever use Windows so these kinds of issues are easy to miss for me :)

Should be available in @ngx-playwright/test version 0.5.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants