Skip to content

getDirname

type: function

The getDirname function resolves the directory path of a module file in ESM environments.

Use it when you need __dirname-like behavior with import.meta.url.

Usage

import { getDirname } from '@mustib/utils/node';
const __dirname = getDirname(import.meta.url);

Definition

function getDirname(metaUrl: string): string { }

Parameters

  1. metaUrl
    type metaUrl = string;
    • Usually the value of `import.meta.url` from the current module.

Returns

type T = string;
  • Absolute directory path for the provided module URL.