# current-module-paths

> Access to __filename and __dirname within ECMAScript modules

Latest version **1.1.3** (published 2025-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install current-module-paths
pnpm add current-module-paths
yarn add current-module-paths
bun add current-module-paths
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2025-11-09 |
| First published | 2021-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=12.17 |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Lloyd Brookes |
| Maintainers | 75lb |
| Keywords | __dirname, __filename, module, paths, modules, ESM, ECMAScript, import, commonjs, cjs, mjs |

## Links

- npm: https://www.npmjs.com/package/current-module-paths
- Repository: https://github.com/75lb/current-module-paths
- Homepage: https://github.com/75lb/current-module-paths#readme
- Issues: https://github.com/75lb/current-module-paths/issues
- npm.io page: https://npm.io/package/current-module-paths

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.1.3 (latest) — 2025-11-09
- 1.1.2 — 2024-08-24
- 1.1.1 — 2023-05-02
- 1.1.0 — 2021-08-13
- 1.0.0 — 2021-07-03
- 0.1.0 — 2021-04-25

## README

[![view on npm](https://badgen.net/npm/v/current-module-paths)](https://www.npmjs.org/package/current-module-paths)
[![npm module downloads](https://badgen.net/npm/dt/current-module-paths)](https://www.npmjs.org/package/current-module-paths)
[![Gihub repo dependents](https://badgen.net/github/dependents-repo/75lb/current-module-paths)](https://github.com/75lb/current-module-paths/network/dependents?dependent_type=REPOSITORY)
[![Gihub package dependents](https://badgen.net/github/dependents-pkg/75lb/current-module-paths)](https://github.com/75lb/current-module-paths/network/dependents?dependent_type=PACKAGE)
[![Node.js CI](https://github.com/75lb/current-module-paths/actions/workflows/node.js.yml/badge.svg)](https://github.com/75lb/current-module-paths/actions/workflows/node.js.yml)

# current-module-paths

Access to the CommonJS `__filename` and `__dirname` variables within ECMAScript modules.

Only use this module if your code depends on the above global variables being defined, otherwise use [import.meta](https://nodejs.org/docs/latest/api/esm.html#no-__filename-or-__dirname).


```js
import currentModulePaths from 'current-module-paths'

const { __filename, __dirname } = currentModulePaths(import.meta.url)
```

* * *

&copy; 2021-25 [Lloyd Brookes](https://github.com/75lb) \<opensource@75lb.com\>.

---
_Source: https://npm.io/package/current-module-paths · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
