Skip to main content
Bun provides a handful of module-specific utilities on the import.meta object. Use import.meta.main to check if the current file is the entrypoint of the current process.
https://mintcdn.com/bun-1dd33a4e-claude-spawn-pty-support/QoBJ_wda4qs1OZ4-/icons/typescript.svg?fit=max&auto=format&n=QoBJ_wda4qs1OZ4-&q=85&s=7e69f1d0981fed9617c1ae7f85ad9758index.ts
if (import.meta.main) {
  // this file is directly executed with `bun run`
} else {
  // this file is being imported by another file
}

See Docs > API > import.meta for complete documentation.