Const
Determines whether the current runtime provides the CommonJS __filename variable.
__filename
true if __filename is available in the current runtime; otherwise false.
true
false
if (hasCommonJSFilename) { console.log("Running in CommonJS environment");} else { console.log("Running in ESM environment"); Copy
if (hasCommonJSFilename) { console.log("Running in CommonJS environment");} else { console.log("Running in ESM environment");
Determines whether the current runtime provides the CommonJS
__filenamevariable.