Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to detect js module was required

if (require.main === module) {
    console.log('called directly');
} else {
    console.log('required as a module');
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #detect #js #module #required
ADD COMMENT
Topic
Name
7+8 =