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
I use this option, since the path starts with file:// just remove that part.
file://
const __filename = import.meta.url.slice(7); const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/"));