Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

node js check if called from module

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