From eea16824bd2f0322032a83ea0e82356a7f172ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Thu, 23 Mar 2023 21:17:07 +0900 Subject: [PATCH] fix: avoid crash because of no access permission (#12552) --- packages/vite/src/node/plugins/resolve.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index bc71e4a67db50c..59aa26fbdf2886 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -138,10 +138,7 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin { // back to checking the path as absolute. If /root/root isn't a valid path, we can // avoid these checks. Absolute paths inside root are common in user code as many // paths are resolved by the user. For example for an alias. - const rootInRoot = - fs - .statSync(path.join(root, root), { throwIfNoEntry: false }) - ?.isDirectory() ?? false + const rootInRoot = tryStatSync(path.join(root, root))?.isDirectory() ?? false return { name: 'vite:resolve',