Skip to main content

Get the absolute path to the current entrypoint

The Bun.main property contains the absolute path to the current entrypoint.

foo.tsindex.ts

console.log(Bun.main);

The printed path is the file executed with bun run.

bun run index.ts
/path/to/index.ts
bun run foo.ts
/path/to/foo.ts

See Utils.

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