title: Detect if called through require or directly by command line
body: <p>How can I detect whether my Node.JS file was called using SH:<code>node path-to-file</code> or JS:<code>require('path-to-file')</code>?</p>
  
  <p>This is the Node.JS equivalent to my previous question in Perl: <a href="https://stackoverflow.com/questions/4004466/how-can-i-run-my-perl-script-only-if-it-wasnt-loaded-with-require">How can I run my Perl script only if it wasn&#39;t loaded with require?</a></p>