> ## Documentation Index
> Fetch the complete documentation index at: https://bun.ll1025.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取当前入口点的绝对路径

`Bun.main` 属性包含当前入口点的绝对路径。

<CodeGroup>
  ```ts foo.ts icon="https://mintcdn.com/span-inc/82N53aP7NFbaCVSl/icons/typescript.svg?fit=max&auto=format&n=82N53aP7NFbaCVSl&q=85&s=787d39d6a7d96d7f9540dc74344eba23" theme={null}
  console.log(Bun.main);
  ```

  ```ts index.ts icon="https://mintcdn.com/span-inc/82N53aP7NFbaCVSl/icons/typescript.svg?fit=max&auto=format&n=82N53aP7NFbaCVSl&q=85&s=787d39d6a7d96d7f9540dc74344eba23" theme={null}
  import "./foo.ts";
  ```
</CodeGroup>

***

打印的路径是使用 `bun run` 执行的文件。

```sh terminal icon="terminal" theme={null}
bun run index.ts
```

```txt theme={null}
/path/to/index.ts
```

```sh terminal icon="terminal" theme={null}
bun run foo.ts
```

```txt theme={null}
/path/to/foo.ts
```

***

参见 [工具](/runtime/utils)。
