Skip to main content
Bun home page
Search...
⌘K
Install Bun
Search...
Navigation
Utilities
Get the directory of the current file
Runtime
Package Manager
Bundler
Test Runner
Guides
Reference
Blog
Feedback
Overview
Guides
Runtime & Debugging
TypeScript types
Re-map import paths
VS Code debugger
Web debugger
Heap snapshots
Build-time constants
Define constants
GitHub Actions
Codesign on macOS
Utilities
Detect Bun
Get Bun version
Hash password
Generate UUID
Base64 encoding
Gzip compression
DEFLATE compression
Escape HTML
Deep equality
Sleep
File URL to path
Path to file URL
Find executable path
import.meta.dir
import.meta.file
import.meta.path
Check entrypoint
Get entrypoint path
Deployment
Deploy on Railway
Deploy on Render
Ecosystem & Frameworks
Astro with Bun
Discord.js with Bun
Docker with Bun
Drizzle with Bun
EdgeDB with Bun
Elysia with Bun
Express with Bun
Hono with Bun
Mongoose with Bun
Neon Drizzle with Bun
Neon Serverless Postgres with Bun
Next.js with Bun
Nuxt with Bun
PM2 with Bun
Prisma with Bun
Qwik with Bun
React with Bun
Remix with Bun
Sentry with Bun
SolidStart with Bun
SSR React with Bun
StricJS with Bun
SvelteKit with Bun
systemd with Bun
Vite with Bun
HTTP & Networking
HTTP Server with Bun
Simple HTTP Server with Bun
Fetch with Bun
Hot reload an HTTP server
Start a cluster of HTTP servers
Configure TLS
Proxy HTTP requests using fetch()
Stream file response
Upload files via HTTP using FormData
Fetch with unix domain sockets
Stream with iterators
Stream with Node.js
WebSocket
Simple server
Pub-sub server
Contextual data
Enable compression
Processes & System
Spawn child process
Read stdout
Read stderr
Parse command-line arguments
Read from stdin
Spawn a child process and communicate using IPC
Listen for CTRL+C
OS signals
Process uptime
Run shell command
Set time zone
Set env variables
Read env variables
Package Manager
Add a dependency
Add a dev dependency
Add an optional dependency
Add a peer dependency
Add a Git dependency
Add a tarball dependency
Install with alias
Workspaces with Bun
Override the default npm registry
Configure a scoped registry
Azure Artifacts with Bun
JFrog Artifactory with Bun
Add a trusted dependency
Generate a yarn-compatible lockfile
Migrate from npm to bun
Configure git to diff Bun's lockfile
Install Bun in GitHub Actions
Test Runner
Run tests
Watch mode
Migrate from Jest
Mock functions
Spy on methods
Mock system time
Snapshot testing
Update snapshots
Coverage reports
Coverage threshold
Skip tests
Todo tests
Test timeout
Bail early
Re-run tests
Testing Library
DOM tests
Test Svelte
Runtime & Debugging
VS Code debugger
Web debugger
Heap snapshots
Build-time constants
Define constants
GitHub Actions
Codesign on macOS
Module System
Import JSON
Import TOML
Import YAML
Import HTML
import.meta.dir
import.meta.file
import.meta.path
Check entrypoint
Get entrypoint path
File System
Read as string
Read to Buffer
Read to Uint8Array
Read to ArrayBuffer
Read JSON file
Get MIME type
Check file exists
Watch directory
Read as stream
Write string to file
Write Blob
Write Response
Append to file
Incremental write
Write stream
Write to stdout
Write file to stdout
Copy file
Delete file
Delete files
Delete directories
Utilities
Hash password
Generate UUID
Base64 encoding
Gzip compression
DEFLATE compression
Escape HTML
Deep equality
Sleep
File URL to path
Path to file URL
Find executable path
HTML Processing
Extract links using HTMLRewriter
OpenGraph tags
Binary Data
ArrayBuffer to string
ArrayBuffer to Buffer
ArrayBuffer to Blob
ArrayBuffer to Array
ArrayBuffer to Uint8Array
Buffer to string
Buffer to ArrayBuffer
Buffer to Blob
Buffer to Uint8Array
Buffer to ReadableStream
Blob to string
Blob to ArrayBuffer
Blob to Uint8Array
Blob to DataView
Blob to ReadableStream
Uint8Array to string
Uint8Array to ArrayBuffer
Uint8Array to Buffer
Uint8Array to Blob
Uint8Array to DataView
Uint8Array to ReadableStream
DataView to string
Streams
Stream to string
Stream to JSON
Stream to Blob
Stream to Buffer
Stream to ArrayBuffer
Stream to Uint8Array
Stream to array
Readable to string
Readable to JSON
Readable to Blob
Readable to Uint8Array
Readable to ArrayBuffer
Utilities
Get the directory of the current file
Copy page
Copy page
Bun provides a handful of module-specific utilities on the
import.meta
object.
/a/b/c.ts
Copy
Ask AI
import
.
meta
.dir;
// => "/a/b"
See
Docs > API > import.meta
for complete documentation.
Was this page helpful?
Yes
No
Get the path to an executable bin file
Previous
Get the file name of the current file
Next
⌘I