Skip to content

Instantly share code, notes, and snippets.

@jaydenseric
Created May 3, 2021 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaydenseric/f8a2d7f3d920f2068de3c958fb6f3d58 to your computer and use it in GitHub Desktop.
Save jaydenseric/f8a2d7f3d920f2068de3c958fb6f3d58 to your computer and use it in GitHub Desktop.
How to get the `__dirname` in a Node.js ESM module.
import { fileURLToPath } from 'url';
const __dirname = fileURLToPath(new URL('./', import.meta.url));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment