https://github.com/keidrun/dirfilename
Alternatives to __dirname and __filename when using ES modules.
https://github.com/keidrun/dirfilename
dirname esm filename import meta
Last synced: over 1 year ago
JSON representation
Alternatives to __dirname and __filename when using ES modules.
- Host: GitHub
- URL: https://github.com/keidrun/dirfilename
- Owner: keidrun
- License: mit
- Created: 2022-04-06T11:18:48.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-03T07:36:17.000Z (almost 4 years ago)
- Last Synced: 2025-03-13T09:04:24.289Z (over 1 year ago)
- Topics: dirname, esm, filename, import, meta
- Language: TypeScript
- Homepage:
- Size: 216 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dirfilename
[](https://npmjs.org/package/dirfilename) [](https://github.com/keidrun/dirfilename/actions/workflows/publish.yml) [](https://codecov.io/gh/keidrun/dirfilename) [](https://snyk.io/test/github/keidrun/dirfilename) [](https://opensource.org/licenses/MIT)
Alternatives to `__dirname` and `__filename` when using ES modules.
## Install
```shell
npm i dirfilename
```
## Usage
```typescript
import { dirname, filename } from 'dirfilename'
const __dirname = dirname(import.meta.url)
const __filename = filename(import.meta.url)
```
Or
```typescript
import { dirname, filename } from 'dirfilename/async'
const __dirname = await dirname(import.meta.url)
const __filename = await filename(import.meta.url)
```