Created
May 22, 2020 17:16
-
-
Save nmccready/5ef54fcc13108837fcdbd6d1b09c19bd to your computer and use it in GitHub Desktop.
es6 modules globals lost in node 12, 14 when in es6 mode
This file contains hidden or 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
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