Skip to content

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

Open
TayyabHussain03 wants to merge 1 commit into
cobusgreyling:mainfrom
TayyabHussain03:fix/windows-esm-pathToFileURL-files-test
Open

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

Conversation

@TayyabHussain03

@TayyabHussain03 TayyabHussain03 commented Aug 11, 2026

Copy link
Copy Markdown

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 ✓

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.

1 participant