Checks whether Node.js is running a global module
There are times that you need to know whether Node.js is executing a global module, typically when you're writing a third-party module and want to execute different pieces of code depending on the current context; local or global module.
On Windows the
PATH environment variable is read to check the context. Node.js scripts running inside the npm install directory will always return true, eg:
cd C:\Users\<user>\AppData\Roaming\npmnode app.js
Therefore, don't run scripts from inside the npm install directory. No one does that so you can assume that on Windows platform it detects the global module execution correctly.
Returns true if Node.js is executing a global module, otherwise false.
var isGlobal = require "is-global";if isGlobalelse