ES Module Main Check

JSON →
library 1.4.0 ·javascript maintenance
verified May 27, 2026

es-main is a utility package designed to replicate the CommonJS `require.main === module` check for ES modules in Node.js environments. It allows developers to determine if an ES module is being executed directly as the main entry point, enabling conditional logic for scripts that can be both imported and run independently. The package is currently at version `1.4.0` and has seen updates primarily to incorporate newer Node.js features, like utilizing `import.meta.main` when available, and for development dependency maintenance. While es-main offers a crucial workaround for older Node.js versions lacking a native equivalent, recent Node.js releases (>= 22.18.0 or 24.2.0) now provide `import.meta.main` directly, rendering es-main largely redundant for modern applications using those versions. Its primary differentiation lies in providing compatibility for environments where `import.meta.main` is not yet implemented.

total hits 8
actors 5 distinct systems
last hit 8d ago AhrefsBot
GPTBot
2
Script
1
ClaudeBot
1
Search engines
1

top countries 🇺🇸 United States · 🇨🇦 Canada · 🇫🇷 France · 🇩🇪 Germany