esm-pathnames

You can use __dirname and __filename when using ESM

Usage no npm install needed!

<script type="module">
  import esmPathnames from 'https://cdn.skypack.dev/esm-pathnames';
</script>

README

ESM-PathNames

You can use __dirname and __filename when using ESM(ECMAScript module).

Install

npm i esm-pathnames

Usage

import { getPathNames } from 'esm-pathnames';

const { __dirname, __filename } = getPathNames(import.meta);

Restrictions

  • The browser environment is not yet supported.