Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vdegenne/es-dirname

Node.js module that returns the current script dirname (esm support)
https://github.com/vdegenne/es-dirname

Last synced: about 1 month ago
JSON representation

Node.js module that returns the current script dirname (esm support)

Awesome Lists containing this project

README

        

# es-dirname

Node.js module that returns the current script dirname. Similar to `__dirname` but also works in ES modules.

## Installation

```yarn add es-dirname```

## Usage

### /path/to/the/script.mjs

```javascript
import dirname from 'es-dirname'

console.log(dirname()) // outputs "/path/to/the"
```

### CommonJs

```javascript
console.log(require('es-dirname')() === __dirname) // true
```