@@ -2,6 +2,7 @@ import fs from 'node:fs'
22import fsp from 'node:fs/promises'
33import path from 'node:path'
44import { pathToFileURL } from 'node:url'
5+ import { promisify } from 'node:util'
56import { performance } from 'node:perf_hooks'
67import { createRequire } from 'node:module'
78import colors from 'picocolors'
@@ -69,6 +70,7 @@ import type { ResolvedSSROptions, SSROptions } from './ssr'
6970import { resolveSSROptions } from './ssr'
7071
7172const debug = createDebugger ( 'vite:config' )
73+ const promisifiedRealpath = promisify ( fs . realpath )
7274
7375export type {
7476 RenderBuiltAssetUrl ,
@@ -1106,7 +1108,11 @@ async function loadConfigFromBundledFile(
11061108 // for cjs, we can register a custom loader via `_require.extensions`
11071109 else {
11081110 const extension = path . extname ( fileName )
1109- const realFileName = await fsp . realpath ( fileName )
1111+ // We don't use fsp.realpath() here because it has the same behaviour as
1112+ // fs.realpath.native. On some Windows systems, it returns uppercase volume
1113+ // letters (e.g. "C:\") while the Node.js loader uses lowercase volume letters.
1114+ // See https://github.com/vitejs/vite/issues/12923
1115+ const realFileName = await promisifiedRealpath ( fileName )
11101116 const loaderExt = extension in _require . extensions ? extension : '.js'
11111117 const defaultLoader = _require . extensions [ loaderExt ] !
11121118 _require . extensions [ loaderExt ] = ( module : NodeModule , filename : string ) => {
0 commit comments