Skip to content

Instantly share code, notes, and snippets.

@himalay
Created November 18, 2022 14:56
Show Gist options
  • Save himalay/c3f8ee776b2f9aa20c493cd0784ca495 to your computer and use it in GitHub Desktop.
Save himalay/c3f8ee776b2f9aa20c493cd0784ca495 to your computer and use it in GitHub Desktop.
Nodejs Global Variables in ES Module
import path from 'path';
import {fileURLToPath} from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
console.log('file-name 👉️', __filename);
console.log('directory-name 👉️', __dirname);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment