if (!module.parent) {
  // this is the main module
} else {
  // we were require()d from somewhere else
}
"node.js equivalent of python's if __name__ == '__main__' "
node.js equivalent of python's if __name__ == '__main__' - Stack Overflow
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
}