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

ESM imports on Windows fail with ERR_UNSUPPORTED_ESM_URL_SCHEME #3584

Closed
nchevsky opened this issue Jan 24, 2023 · 0 comments · Fixed by #3585
Closed

ESM imports on Windows fail with ERR_UNSUPPORTED_ESM_URL_SCHEME #3584

nchevsky opened this issue Jan 24, 2023 · 0 comments · Fixed by #3585

Comments

@nchevsky
Copy link
Contributor

nchevsky commented Jan 24, 2023

Description of the bug/issue

💡 PR: #3585

In ESM projects running on Windows, when Nightwatch attempts to import() a custom assertion, custom command, or page object, it fails as follows:

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                   │
│   There was an error while trying to load the file                                                                │
│   C:\foo\bar.js:                                                                                                  │
│   [ERR_UNSUPPORTED_ESM_URL_SCHEME] Only URLs with a scheme in: file, data are supported by the default ESM        │
│   loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:';                          │
│                                                                                                                   │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Switching to CommonJS, or running on a *nix operating system, works around the problem.

CommonJS ESM
*nix ✔️ ✔️
Windows ✔️

Steps to reproduce

>git clone https://github.com/nchevsky/nightwatch-repro.git
>cd nightwatchjs-repro
>npm i -D
>npx nightwatch

Actual

There was an error while trying to load the file
C:\…\nightwatch-repro\nightwatch\custom-assertions\trueEqualsTrue.js:
[ERR_UNSUPPORTED_ESM_URL_SCHEME] Only URLs with a scheme in: file, data are supported by the default ESM
loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:';

Expected

[Esm Import Of Custom Assertion] Test Suite
───────────────────────────────────────────────────────────────────────────────
Using: chrome (109.0.5414.120) on WINDOWS.

– ESM import of custom assertion
√ true equals true (0ms)

Nightwatch.js Version

2.6.10

Node Version

18.12.1

Operating System

Windows 11

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 a pull request may close this issue.

1 participant