You can use __dirname and __filename when using ESM
npm install esm-pathnamesYou can use __dirname and __filename when using ESM(ECMAScript module).
``shell`
npm i esm-pathnames
`js
import { getPathNames } from 'esm-pathnames';
const { __dirname, __filename } = getPathNames(import.meta);
``
- The browser environment is not yet supported.