Mimicking __dirname and __filename in ESM modules in Node.js

1 · Nicholas C. Zakas · Jan. 18, 2023, midnight
One of the things that I miss most about using ESM is the lack of __dirname and __filename. Here's how to recreate those variables....