Skip to content

Instantly share code, notes, and snippets.

@nmccready
Created May 22, 2020 17:16
Show Gist options
  • Save nmccready/5ef54fcc13108837fcdbd6d1b09c19bd to your computer and use it in GitHub Desktop.
Save nmccready/5ef54fcc13108837fcdbd6d1b09c19bd to your computer and use it in GitHub Desktop.
es6 modules globals lost in node 12, 14 when in es6 mode
import { dirname } from 'path';
import { fileURLToPath } from 'url';
// this is rediculous, node 14 / 12 breaking backwards compat
export const __filename = fileURLToPath(import.meta.url);
export const __dirname = dirname(__filename);
global.__filename = __filename;
global.__dirname = __dirname;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment