Skip to content

Commit

Permalink
fix: catch statSync error (#11907)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Feb 2, 2023
1 parent 1df2cfc commit f80b9a2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,13 @@ function tryResolveFile(
skipPackageJson?: boolean,
skipTsExtension?: boolean,
): string | undefined {
const stat = fs.statSync(file, { throwIfNoEntry: false })
let stat: fs.Stats | undefined
try {
stat = fs.statSync(file, { throwIfNoEntry: false })
} catch {
return
}

if (stat) {
if (!stat.isDirectory()) {
return getRealPath(file, options.preserveSymlinks) + postfix
Expand Down

0 comments on commit f80b9a2

Please sign in to comment.