Created
April 18, 2024 05:09
-
-
Save isuvorov/542c7c1b3ed140da13c8242c6316dcee to your computer and use it in GitHub Desktop.
ESM __dirname and __filename
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { dirname } from 'node:path'; | |
import { fileURLToPath } from 'node:url'; | |
export const getFilename = (meta) => fileURLToPath(meta.url); | |
export const getDirname = (meta) => dirname(getFilename(meta)); | |
const __filename = getFilename(import.meta); | |
const __dirname = getDirname(import.meta); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment