Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:' #12307

Closed
frederikhors opened this issue Feb 23, 2022 · 3 comments · Fixed by #12357
Assignees

Comments

@frederikhors
Copy link

frederikhors commented Feb 23, 2022

Context:

  • Playwright Version: @playwright/test: 1.19.1
  • Browser: Chrome
  • OS: Windows 10 10.0.19044
  • Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
  • npm: 8.5.1 - C:\Program Files\nodejs\npm.CMD

REPL:

https://github.com/frederikhors/iss-playwright-typescript

Describe the bug

@mxschmitt asked me to open a new issue here: #12138 (comment).

The issue is:

@bbigras here suggests how to work with Typescript using PW_EXPERIMENTAL_TS_ESM.

On Windows 10 this doesn't work:

(node:12372) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
    at new NodeError (node:internal/errors:371:5)
    at throwIfUnsupportedURLProtocol (node:internal/modules/esm/resolve:1033:11)
    at defaultResolve (node:internal/modules/esm/resolve:1103:3)
    at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
    at ESMLoader.import (node:internal/modules/esm/loader:332:22)
    at initializeLoader (node:internal/process/esm_loader:74:49)
    at loadESM (node:internal/process/esm_loader:87:11)
    at runMainESM (node:internal/modules/run_main:51:21)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:74:5) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

WSL is not an option because I cannot install it and I wanna use Windows 10 natively.

@mxschmitt
Copy link
Member

@frederikhors could you provide us a minimal reproducible? So we know how your code looks like, maybe there is some kind of "interesting" import which our transformation logic does not take care of.

Also your tsconfig might be useful.

@frederikhors
Copy link
Author

REPL: https://github.com/frederikhors/iss-playwright-typescript

If you run npx playwright test:

Error: playwright.config.ts: Cannot import a typescript file from an esmodule.

If you run $env:PW_EXPERIMENTAL_TS_ESM="1"; npx playwright test or $env:PW_EXPERIMENTAL_TS_ESM=1; npx playwright test:

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

@mxschmitt
Copy link
Member

@frederikhors very helpful! Thank you. Found the bug and created a PR to fix it.

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