Skip to content

isMainModule

Generated reference page for the isMainModule function export.

Signatures

ts
function isMainModule(meta: ImportMeta): boolean;
ParameterTypeDescription
metaImportMetaThe calling module's import.meta.

Members

Members

isMainModule

Report whether the calling module is the process entrypoint, cross-runtime.

Node, Bun, and Deno set import.meta.main on the module invoked directly; projects with the runtime's ambient types can read that property directly. This helper is a compatibility form for projects whose tsconfig.json lib override drops those ImportMeta extras: passing import.meta whole avoids a direct .main access without requiring global augmentation.

ts
(meta: ImportMeta): boolean;

Examples

ts
if (isMainModule(import.meta)) cli('mycli').command(deploy).run();

See Also

Released under the MIT License.