From 6bd543421e8479c311750fceb119a0b5a48c7703 Mon Sep 17 00:00:00 2001 From: Ilia <92597193+datacutter@users.noreply.github.com> Date: Tue, 18 Jul 2023 19:52:58 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20"EISDIR:=20illegal=20operation=20on=20a?= =?UTF-8?q?=20directory,=20realpath"=20error=20on=20RA=E2=80=A6=20(#13655)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: patak --- packages/vite/src/node/utils.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 1ac8617f6bc7ac..9ddc8c3a1f7791 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -608,7 +608,17 @@ function optimizeSafeRealPathSync() { safeRealpathSync = fs.realpathSync return } - + // Check the availability `fs.realpathSync.native` + // in Windows virtual and RAM disks that bypass the Volume Mount Manager, in programs such as imDisk + // get the error EISDIR: illegal operation on a directory + try { + fs.realpathSync.native(path.resolve('./')) + } catch (error) { + if (error.message.includes('EISDIR: illegal operation on a directory')) { + safeRealpathSync = fs.realpathSync + return + } + } exec('net use', (error, stdout) => { if (error) return const lines = stdout.split('\n')