Skip to main content

Get the directory of the current file

Bun provides a handful of module-specific utilities on the import.meta object. Use import.meta.dir to retrieve the absolute path to the directory containing the current file.

import.meta.dir; // => "/a/b"

See import.meta.

Translation © 2026 fanyi.dev · Original © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)