ES Module Main Check
JSON →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.
Traffic · last 30 days ↓100% vs prev 7d
top countries 🇺🇸 United States · 🇨🇦 Canada · 🇫🇷 France · 🇩🇪 Germany