title: Determining Node modules location at runtime
body: <p>I am building a tool which is basically a node.js module. This tool can be installed globally (with <code>-g</code> option) I have few static files in the module to generate a report. If the module is invoked locally, I can refer to the static files with relative path <code>./node_modules/&lt;module&gt;/static/filename</code>. But when the tool is invoked as a command, how do I refer to the static files? And how can I determine whether the tool is invoked as a local module or as a command?</p>