Skip to main content

Check if a file exists

还没翻译译自英文(bun.com)本页 3 段都还没译

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.

번역 © 2026 fanyi.dev · 원문 © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)