I use the flag --experimental-modules when running my node application in order to use ES6 modules.
--experimental-modules
However when I use this flag the metavariable
As of Node.js 10.12 there's an alternative that doesn't require creating multiple files and handles special characters in filenames across platforms:
import { dirname } from 'path'; import { fileURLToPath } from 'url'; const __dirname = dirname(fileURLToPath(import.meta.url));