Skip to content

Instantly share code, notes, and snippets.

@Kirill89
Created July 12, 2022 09:27
Show Gist options
  • Save Kirill89/7f76f5bd36f878cbc5f03218b9e10620 to your computer and use it in GitHub Desktop.
Save Kirill89/7f76f5bd36f878cbc5f03218b9e10620 to your computer and use it in GitHub Desktop.
How to get __dirname in mjs
import path from 'node:path';
import {fileURLToPath} from 'node:url';
const SCRIPT_FOLDER = path.dirname(fileURLToPath(import.meta.url));
const DATA_FOLDER = path.join(SCRIPT_FOLDER, 'data');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment