Skip to content

fix(vite-plugin-uni): 修复 Windows 下 UTS 模块解析路径#5992

Open
6iedog wants to merge 1 commit into
dcloudio:uni-app-vue3-devfrom
6iedog:fix/windows-node24-uts-fs-prefix
Open

fix(vite-plugin-uni): 修复 Windows 下 UTS 模块解析路径#5992
6iedog wants to merge 1 commit into
dcloudio:uni-app-vue3-devfrom
6iedog:fix/windows-node24-uts-fs-prefix

Conversation

@6iedog

@6iedog 6iedog commented Apr 29, 2026

Copy link
Copy Markdown

Summary

Fix Windows + Node.js v24 compatibility for app UTS module resolution in dev mode.

When app UTS modules are resolved to raw Windows absolute paths like C:/..., Vite may eventually pass them into ESM import flow, which can trigger:

ERR_UNSUPPORTED_ESM_URL_SCHEME
Only URLs with a scheme in: file, data, and node are supported...
Received protocol 'd:'
This patch makes the app UTS resolver return Vite-compatible /@fs/ module ids on Windows instead of bare absolute paths.

Changes

update packages/vite-plugin-uni/src/config/resolve.ts
prefix Windows app UTS resolved paths with FS_PREFIX
preserve existing non-Windows behavior
add packages/vite-plugin-uni/tests/resolve.spec.ts
cover Windows app UTS resolver output for ?uts-proxy

Why here

The failing path is in the dev resolver used by vite-plugin-uni, and this is the smallest upstream-compatible fix:

it keeps existing UTS resolution logic
it follows Vite’s existing /@fs/ convention for filesystem paths
it avoids relying on Node loader hooks or user-side workarounds

Verification

Passed:

pnpm exec jest --runInBand --runTestsByPath "packages/vite-plugin-uni/tests/resolve.spec.ts"
pnpm exec jest --runInBand packages/vite-plugin-uni/tests/static.spec.ts packages/vite-plugin-uni/tests/sourcemap.spec.ts

Context

This addresses a Windows + Node.js v24 issue where bare absolute filesystem paths are no longer accepted when they later reach ESM import handling.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@WuChenDi

WuChenDi commented Jul 7, 2026

Copy link
Copy Markdown

Thanks @6iedog for putting this fix together! 🙏

We're running into the exact same ERR_UNSUPPORTED_ESM_URL_SCHEME on Windows + Node.js v24 when building with uni build -p mp-weixin on the latest @dcloudio/* (3.0.0-5.x). Linux/macOS builds are unaffected, which lines up perfectly with the analysis here.

Would a maintainer be able to review and merge this when time permits? It currently blocks Windows + Node 24 builds, and the /@fs/ approach looks like the minimal, Vite-idiomatic fix. Happy to help test it against our project if that would be useful.

Thanks for the great work on uni-app! 🚀

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