Sha256: 7a6c7862ecbd1eacc3bca388d4aaa93a6fe03deeaf2acf4522eaff0405e96e0c
Contents?: true
Size: 691 Bytes
Versions: 32
Compression:
Stored size: 691 Bytes
Contents
### Install ```shell npm install --save detect-node ``` ### Usage: ```js var isNode = require('detect-node'); if (isNode) { console.log("Running under Node.JS"); } else { alert("Hello from browser (or whatever not-a-node env)"); } ``` The check is performed as: ```js module.exports = false; // Only Node.JS has a process variable that is of [[Class]] process try { module.exports = Object.prototype.toString.call(global.process) === '[object process]' } catch(e) {} ``` Thanks to Ingvar Stepanyan for the initial idea. This check is both **the most reliable I could find** and it does not use `process` env directly, which would cause browserify to include it into the build.
Version data entries
32 entries across 31 versions & 10 rubygems