Skip to content

ERR_UNSUPPORTED_ESM_URL_SCHEME on Windows - dynamic import needs pathToFileURL #51

@thelandinlook

Description

@thelandinlook

Bug Description

The npm package fails on Windows with ERR_UNSUPPORTED_ESM_URL_SCHEME when running claude-self-reflect setup.

Environment

  • OS: Windows 11
  • Node: v22.19.0 (also tested v20.x - same issue)
  • Package version: 2.8.10
  • Installation method: npm install -g claude-self-reflect

Error

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:'
at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:184:11)
at defaultLoad (node:internal/modules/esm/load:82:3)
at ModuleLoader.load (node:internal/modules/esm/loader:801:12)

Root Cause

installer/setup-wizard.js line 9 uses a dynamic import with a Windows path instead of a file:// URL:

import(join(__dirname, 'setup-wizard-docker.js'));

On Windows, ESM dynamic imports require file:// URLs, not filesystem paths.

Fix

import { fileURLToPath, pathToFileURL } from 'url';
// ...
import(pathToFileURL(join(__dirname, 'setup-wizard-docker.js')).href);

Notes

  • This only affects Windows users using the npm package
  • Mac/Linux users are unaffected (Unix paths work with dynamic imports)
  • The same pattern might exist in other files

Reproduction

  1. Windows machine with Node 20+
  2. npm install -g claude-self-reflect
  3. claude-self-reflect setup

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions