desm
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

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

import desm from 'desm'

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

or

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.3.1
    306,693
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.3.1
    306,693
  • 1.3.0
    153,073
  • 1.2.0
    228
  • 1.1.0
    11
  • 1.0.0
    3

Package Sidebar

Install

npm i desm

Weekly Downloads

460,008

Version

1.3.1

License

MIT

Unpacked Size

4.69 kB

Total Files

8

Last publish

Collaborators

  • matteo.collina