# desm

> get the file directory from import.meta.url

Latest version **1.3.1** (published 2024-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install desm
pnpm add desm
yarn add desm
bun add desm
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2024-01-17 |
| First published | 2020-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 116 |
| Author | Matteo Collina |
| Maintainers | matteo.collina |
| Keywords | esm, import, url, dirname, __dirname |

## Links

- npm: https://www.npmjs.com/package/desm
- Repository: https://github.com/mcollina/desm
- Homepage: https://github.com/mcollina/desm#readme
- Issues: https://github.com/mcollina/desm/issues
- npm.io page: https://npm.io/package/desm

## 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.3.1 (latest) — 2024-01-17
- 1.3.0 — 2022-05-26
- 1.2.0 — 2021-08-26
- 1.1.0 — 2020-11-29
- 1.0.0 — 2020-06-03

## README

# desm

The missing one-liner utility to get the dirname from `import.meta.url`.

Requires Node 12.17.0 or Node 14.0.0.

## Install

```
npm i desm
```

## Usage

```js
import desm from 'desm'

console.log(desm(import.meta.url))
```

or

```js
import { dirname, filename, join } from 'desm'

// same as CommonJS __dirname
console.log(dirname(import.meta.url))

// same as CommonJS __filename
console.log(filename(import.meta.url))

// same as CommonJS path.join(__dirname, 'routes')
console.log(join(import.meta.url, 'routes'))

// same as CommonJS path.join(__dirname, '..', 'other')
console.log(join(import.meta.url, '..', 'other'))
```

## License

MIT

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