How can I detect whether my node.js file was called directly from console (windows and unix systems) or loaded using the ESM module import (import {foo} from 'bar.js')
The question was already answered for regular node.js files (Detect if called through require or directly by command line) but since require is not available in .mjs files with --experimental-modules turned on, I am in need of a different solution.