mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
44 lines
670 B
Plaintext
44 lines
670 B
Plaintext
---
|
|
title: Get the absolute path to the current entrypoint
|
|
sidebarTitle: Get entrypoint path
|
|
mode: center
|
|
---
|
|
|
|
The `Bun.main` property contains the absolute path to the current entrypoint.
|
|
|
|
<CodeGroup>
|
|
|
|
```ts foo.ts icon="/icons/typescript.svg"
|
|
console.log(Bun.main);
|
|
```
|
|
|
|
```ts index.ts icon="/icons/typescript.svg"
|
|
import "./foo.ts";
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
---
|
|
|
|
The printed path corresponds to the file that is executed with `bun run`.
|
|
|
|
```sh terminal icon="terminal"
|
|
bun run index.ts
|
|
```
|
|
|
|
```txt
|
|
/path/to/index.ts
|
|
```
|
|
|
|
```sh terminal icon="terminal"
|
|
bun run foo.ts
|
|
```
|
|
|
|
```txt
|
|
/path/to/foo.ts
|
|
```
|
|
|
|
---
|
|
|
|
See [Docs > API > Utils](/runtime/utils) for more useful utilities.
|