@@ -2,6 +2,7 @@ import fs from 'node:fs'
2
2
import fsp from 'node:fs/promises'
3
3
import path from 'node:path'
4
4
import { pathToFileURL } from 'node:url'
5
+ import { promisify } from 'node:util'
5
6
import { performance } from 'node:perf_hooks'
6
7
import { createRequire } from 'node:module'
7
8
import colors from 'picocolors'
@@ -69,6 +70,7 @@ import type { ResolvedSSROptions, SSROptions } from './ssr'
69
70
import { resolveSSROptions } from './ssr'
70
71
71
72
const debug = createDebugger ( 'vite:config' )
73
+ const promisifiedRealpath = promisify ( fs . realpath )
72
74
73
75
export type {
74
76
RenderBuiltAssetUrl ,
@@ -1106,7 +1108,11 @@ async function loadConfigFromBundledFile(
1106
1108
// for cjs, we can register a custom loader via `_require.extensions`
1107
1109
else {
1108
1110
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 )
1110
1116
const loaderExt = extension in _require . extensions ? extension : '.js'
1111
1117
const defaultLoader = _require . extensions [ loaderExt ] !
1112
1118
_require . extensions [ loaderExt ] = ( module : NodeModule , filename : string ) => {
0 commit comments