"node.js equivalent of python's if __name__ == '__main__' "

published May 25, 2016 03:15   by admin ( last modified May 25, 2016 03:16 )

node.js equivalent of python's if __name__ == '__main__' - Stack Overflow

 

if (!module.parent) {
  // this is the main module
} else {
  // we were require()d from somewhere else
}