Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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)
- Host: GitHub
- URL: https://github.com/vdegenne/es-dirname
- Owner: vdegenne
- Created: 2019-04-17T16:18:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-07-21T08:49:55.000Z (over 2 years ago)
- Last Synced: 2023-03-02T00:42:02.842Z (almost 2 years ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
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
```