Skip to main content

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.

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.

Translation © 2026 fanyi.dev · Original © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)