ApplesauceOS
Read Markdown ↗Download .md

require.main

Identify the entry module.

js
require.main

Arguments

No arguments.

Returns

Module object with filename, exports and metadata.

Example

js
console.log(require.main.filename);

Notes

A runtime property, not a function. Module state is separate for each script iteration.

All JavaScript APIs · Automation playbook