diff --git a/packages/vite/src/node/fsUtils.ts b/packages/vite/src/node/fsUtils.ts index d16b7ecf13454a..125dd29e3ebabd 100644 --- a/packages/vite/src/node/fsUtils.ts +++ b/packages/vite/src/node/fsUtils.ts @@ -148,11 +148,11 @@ export function createCachedFsUtils(config: ResolvedConfig): FsUtils { return } if (nextDirentCache.type === 'directory_maybe_symlink') { - dirPath ??= pathUntilPart(root, parts, i) + dirPath ??= pathUntilPart(root, parts, i + 1) const isSymlink = fs .lstatSync(dirPath, { throwIfNoEntry: false }) ?.isSymbolicLink() - direntCache.type = isSymlink ? 'symlink' : 'directory' + nextDirentCache.type = isSymlink ? 'symlink' : 'directory' } direntCache = nextDirentCache } else if (direntCache.type === 'symlink') {