Skip to main content

dirname

property ImportMeta.dirname

The absolute path of the directory containing the current module.

This property is only provided for local modules (ie. using file:// URLs).

  • Example:
// Unix
console.log(import.meta.dirname); // /home/alice

// Windows
console.log(import.meta.dirname); // C:\alice
string
Back to top