aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/read-file/exists.md
blob: fd6cbbf9a418d8baa12f95cb57ff3dbec7979f34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
---
name: Check if a file exists
---

The `Bun.file()` function accepts a path and returns a `BunFile` instance. Use the `.exists()` method to check if a file exists at the given path.

```ts
const path = "/path/to/package.json";
const file = Bun.file(path);

file.exists(); // boolean;
```

---

Refer to [API > File I/O](/docs/api/file-io) for more information on working with `BunFile`.