Created
October 25, 2021 05:50
-
-
Save remino/b6c11232786d7b38f44ba8c1b5a4650e to your computer and use it in GitHub Desktop.
Get __filename & __dirname in Node native ES modules
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
// Get __filename & __dirname in Node native ES modules | |
import { URL } from 'url' | |
const __filename = new URL('', import.meta.url).pathname | |
const __dirname = new URL('.', import.meta.url).pathname | |
console.log(__filename) | |
console.log(__dirname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment