Skip to content

fix: Windows ESM import errors in sunpeak CLI#58

Merged
abewheel merged 1 commit intoSunpeak-AI:mainfrom
udaykakade25:fix/windows-esm-import-paths
May 3, 2026
Merged

fix: Windows ESM import errors in sunpeak CLI#58
abewheel merged 1 commit intoSunpeak-AI:mainfrom
udaykakade25:fix/windows-esm-import-paths

Conversation

@udaykakade25
Copy link
Copy Markdown
Contributor

About Issue

Node's ESM loader rejects Windows absolute paths like 'C:...' because it parses the drive letter as a URL scheme. Convert paths to file:// URLs before passing them to dynamic import() and child_process.spawn().

  • bin/sunpeak.js: wrap command imports with pathToFileURL().href so 'sunpeak dev', 'inspect', 'build', etc. load on Windows.
  • bin/commands/dev.mjs: replace 'new URL(import.meta.url).pathname' with 'fileURLToPath(import.meta.url)' to avoid the doubled drive letter ('C:\C:...') that broke the build watcher and the --prod-resources initial build.

BEFORE

 $ pnpm --filter sunpeak dev                                                                 
                                                                                              
  > sunpeak@0.20.12 dev D:\work\sunpeak\packages\sunpeak                                      
  > pnpm -C template dev                                                                      
                                                                                              
                                                                                              
  > sunpeak-app@0.1.0 dev D:\work\sunpeak\packages\sunpeak\template                           
  > sunpeak dev                                                                               
                                                                                              
  Error: 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 'd:'       
   ELIFECYCLE  Command failed with exit code 1.                                               
  D:\work\sunpeak\packages\sunpeak:                                                           
   ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  sunpeak@0.20.12 dev: pnpm -C template dev             
  Exit status 1

AFTER FIX

$ pnpm --filter sunpeak dev  

> sunpeak@0.20.15 dev C:\Users\jayka\OneDrive\Desktop\sunpeak\packages\sunpeak
> pnpm -C template dev


> sunpeak-app@0.1.0 dev C:\Users\jayka\OneDrive\Desktop\sunpeak\packages\sunpeak\template
> sunpeak dev

Starting dev server...

Starting MCP server with 7 simulation(s) (Vite HMR)...
Sunpeak MCP server listening on http://localhost:8000
  MCP endpoint: http://localhost:8000/mcp
  Vite HMR: enabled (source files served with hot reload)
[build] Building resources for the MCP server for non-ChatGPT hosts...
[build] Watching src/resources/ for changes...
Connecting to MCP server: http://localhost:8000/mcp
[MCP] ← initialize
[MCP] Registered 7 tool(s) (6 UI, 1 plain), 4 resource(s)
[MCP] Session started: daa286e4... (local, 1 active)
[MCP] ← notifications/initialized (daa286e4...)
Connected. Discovering tools and resources...
[MCP] ← tools/list (daa286e4...)
[MCP] ← resources/list (daa286e4...)
Found 7 tool(s), 6 resource(s).
10:34:40 pm [vite] (client) Re-optimizing dependencies because vite config has changed
  ➜  Local:   http://localhost:3000/
  ➜  Network: http://10.239.70.135:3000/
  ➜  press h + enter to show help

Node's ESM loader rejects Windows absolute paths like 'C:\...' because it
parses the drive letter as a URL scheme. Convert paths to file:// URLs
before passing them to dynamic import() and child_process.spawn().

- bin/sunpeak.js: wrap command imports with pathToFileURL().href so
  'sunpeak dev', 'inspect', 'build', etc. load on Windows.
- bin/commands/dev.mjs: replace 'new URL(import.meta.url).pathname'
  with 'fileURLToPath(import.meta.url)' to avoid the doubled drive
  letter ('C:\C:\...') that broke the build watcher and the
  --prod-resources initial build.
@abewheel abewheel merged commit 55f7476 into Sunpeak-AI:main May 3, 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