The Bun.main property contains the absolute path to the current entrypoint.
ts
console.log(Bun.main);ts
import "./foo.ts";The printed path corresponds to the file that is executed with bun run.
sh
bun run index.tstxt
/path/to/index.tssh
bun run foo.tstxt
/path/to/foo.tsSee Docs > API > Utils for more useful utilities.