Skip to main content
Bun.file() 函数接受一个路径并返回一个 [BunFile] 实例。使用 .exists() 方法检查给定路径处是否存在文件。
https://mintcdn.com/teemo/2s-4Z6VdGqiCeBNX/icons/typescript.svg?fit=max&auto=format&n=2s-4Z6VdGqiCeBNX&q=85&s=087b260066909db1cd3e9c7292bc34b2index.ts
const path = "/path/to/package.json";
const file = Bun.file(path);

await file.exists(); // boolean;

有关使用 [BunFile] 的更多信息,请参阅 API > 文件 I/O