Skip to content

fix(loop): use pathToFileURL for dynamic import in files.test (Windows) - #502

Merged
cobusgreyling merged 1 commit into
cobusgreyling:mainfrom
TayyabHussain03:fix/windows-esm-pathToFileURL-files-test
Aug 13, 2026
Merged

fix(loop): use pathToFileURL for dynamic import in files.test (Windows)#502
cobusgreyling merged 1 commit into
cobusgreyling:mainfrom
TayyabHussain03:fix/windows-esm-pathToFileURL-files-test

Conversation

@TayyabHussain03

@TayyabHussain03 TayyabHussain03 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Problem

npm test in tools/loop crashes on Windows with:

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

path.resolve() returns a Win32 absolute path (D:\...).
Node's ESM loader rejects this for dynamic import() calls on Windows.
This caused test/files.test.mjs to crash entirely — 0 of 3 tests ran.

Fix

- import { fileURLToPath } from 'node:url';
+ import { fileURLToPath, pathToFileURL } from 'node:url';

- const files = await import(path.resolve(__dirname, '../dist/files.js'));
+ const files = await import(pathToFileURL(path.resolve(__dirname, '../dist/files.js')).href);

pathToFileURL is already available via node:url — one import added, one call wrapped.

Result

Before After
files.test.mjs crash (0/3 ran) ✅ 3/3 pass
Total tools/loop 5/8 pass 8/8 pass*

*2 remaining failures (readiness-core not found, doctor --json) are
a separate monorepo workspace issue — not related to this fix.

Environment

  • Windows 11
  • Node.js v24.14.0
  • Repo cloned to D:\ drive

Checklist

  • Tool change (tools/loop)
  • Ran npm test in tools/loop — 8/8 pass after fix
  • No secrets, tokens, or internal company URLs
  • Allow edits by maintainers ✓

@cobusgreyling

Copy link
Copy Markdown
Owner

Thanks for the Windows ESM fix — this looks useful. CI was waiting on first-time contributor workflow approval; re-running checks now. Will merge once green.

@cobusgreyling
cobusgreyling merged commit 5b57ddc into cobusgreyling:main Aug 13, 2026
2 checks passed
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