Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

node js check if called from command line

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 #command #line
ADD COMMENT
Topic
Name
6+4 =