Skip to content
Bun
Bun
File System

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.

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

await file.exists(); // boolean;

See File I/O for more on working with BunFile.

Was this page helpful?Suggest editsRaise issue