Skip to content

fix: use file:// URL when importing server entry in vite preview#2182

Merged
brenelz merged 2 commits into
mainfrom
fix/windows-preview-esm-url
Jul 16, 2026
Merged

fix: use file:// URL when importing server entry in vite preview#2182
brenelz merged 2 commits into
mainfrom
fix/windows-preview-esm-url

Conversation

@brenelz

@brenelz brenelz commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #2140.

Running vite preview on Windows crashed with ERR_UNSUPPORTED_ESM_URL_SCHEME because the preview middleware dynamically imported the built server entry via a raw absolute path (process.cwd() + "/dist/server/entry-server.js"). On Windows that resolves to a C:\... path, which Node's ESM loader rejects; POSIX paths happen to be accepted, which is why this only broke on Windows.

This converts the path to a proper file:// URL with pathToFileURL (and uses path.join for cross-platform separators) before importing, as suggested in the issue's patch.

Testing

  • pnpm build in packages/start passes (import validation, tsc, build script).
  • Smoke-tested the code path on macOS: built the bare fixture with a plain solidStart() config (no nitro, since nitro outputs to .output/ and bypasses this middleware), ran vite preview, and confirmed a 200 response with fully server-rendered HTML.

🤖 Generated with Claude Code

The preview middleware imported dist/server/entry-server.js via a raw
absolute path, which Node's ESM loader rejects on Windows with
ERR_UNSUPPORTED_ESM_URL_SCHEME. Convert the path with pathToFileURL
before importing.

Fixes #2140

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6dd2b7a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify

netlify Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deploy Preview for solid-start-landing-page ready!

Name Link
🔨 Latest commit 6dd2b7a
🔍 Latest deploy log https://app.netlify.com/projects/solid-start-landing-page/deploys/6a58399f4727990008826937
😎 Deploy Preview https://deploy-preview-2182--solid-start-landing-page.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/solidjs/solid-start/@solidjs/start@2182
npm i https://pkg.pr.new/solidjs/solid-start/@solidjs/vite-plugin-nitro-2@2182

commit: 6dd2b7a

@brenelz brenelz merged commit e263338 into main Jul 16, 2026
10 checks passed
@brenelz brenelz deleted the fix/windows-preview-esm-url branch July 16, 2026 01:55
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.

[Bug?]: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]

3 participants