Skip to content

Commit 6f6e5de

Browse files
sapphi-redbluwy
authored andcommitted
fix: handle errors during hasWorkspacePackageJSON function (#14394)
1 parent 8bc1f9d commit 6f6e5de

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/vite/src/node/server/searchRoot.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ function hasWorkspacePackageJSON(root: string): boolean {
2727
if (!isFileReadable(path)) {
2828
return false
2929
}
30-
const content = JSON.parse(fs.readFileSync(path, 'utf-8')) || {}
31-
return !!content.workspaces
30+
try {
31+
const content = JSON.parse(fs.readFileSync(path, 'utf-8')) || {}
32+
return !!content.workspaces
33+
} catch {
34+
return false
35+
}
3236
}
3337

3438
function hasRootFile(root: string): boolean {

0 commit comments

Comments
 (0)