Answers for "how to detect js module was required"

1

how to detect js module was required

if (require.main === module) {
    console.log('called directly');
} else {
    console.log('required as a module');
}
Posted by: Guest on July-06-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language