> ## 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 在 [`import.meta`](/runtime/module-resolution#import-meta) 对象上提供了一些模块特定的实用工具。使用 `import.meta.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}
if (import.meta.main) {
  // 此文件是直接使用 `bun run` 执行的
} else {
  // 此文件正被另一个文件导入
}
```

***

参见 [`import.meta`](/runtime/module-resolution#import-meta)。
