This won't detect when run from an npm script.  For instance:

```js
{
    "scripts": {
        "cram": "npm run node_modules/cram/cram index.html"
    }
}
```

When running `npm run cram`, `require.main !== module` and cram does nothing :(.