Skip to content

fix(generate-palette): fix ERR_UNSUPPORTED_ESM_URL_SCHEME on Windows - #2

Merged
craftzdog merged 2 commits into
inkdropapp:mainfrom
khouwdevin:fix/esm-url-scheme-windows
Aug 9, 2026
Merged

fix(generate-palette): fix ERR_UNSUPPORTED_ESM_URL_SCHEME on Windows#2
craftzdog merged 2 commits into
inkdropapp:mainfrom
khouwdevin:fix/esm-url-scheme-windows

Conversation

@khouwdevin

@khouwdevin khouwdevin commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Hi Takuya-san,

I found an issue when I migrate theme plugin on Windows, it's error on generate palette, the error was:

Error extracting palette: 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 'd:'

and I'm able to fix it with add pathToFileURL on the import. I'm not able to test on macOS, so it would be great if someone could verify it there too.

@craftzdog craftzdog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment thread src/generate-palette.ts

async function extractPalette(outputPath: string) {
const themePackageJson = (
await import(path.join(process.cwd(), 'package.json'), { with: { type: 'json' } })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pathToFileURL return a URL object. So I think it needs .href like:

await import(pathToFileURL(path.join(process.cwd(), 'package.json')).href, {
  with: { type: 'json' }
})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the fix, it will convert the URL to string, thanks.

@khouwdevin
khouwdevin requested a review from craftzdog August 9, 2026 01:19
@craftzdog
craftzdog merged commit 35213aa into inkdropapp:main Aug 9, 2026
1 check passed
@craftzdog

Copy link
Copy Markdown
Contributor

Thanks, @khouwdevin !

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