Skip to content

Commit f80b9a2

Browse files
authoredFeb 2, 2023
fix: catch statSync error (#11907)
1 parent 1df2cfc commit f80b9a2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎packages/vite/src/node/plugins/resolve.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,13 @@ function tryResolveFile(
536536
skipPackageJson?: boolean,
537537
skipTsExtension?: boolean,
538538
): string | undefined {
539-
const stat = fs.statSync(file, { throwIfNoEntry: false })
539+
let stat: fs.Stats | undefined
540+
try {
541+
stat = fs.statSync(file, { throwIfNoEntry: false })
542+
} catch {
543+
return
544+
}
545+
540546
if (stat) {
541547
if (!stat.isDirectory()) {
542548
return getRealPath(file, options.preserveSymlinks) + postfix

0 commit comments

Comments
 (0)
Please sign in to comment.