2.1.0 • Published 4 years ago

detect-node v2.1.0

Weekly downloads
8,766,083
License
MIT
Repository
github
Last release
4 years ago

Install

npm install --save detect-node

Usage:

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:

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.

spdy-transport@noir-lang/noir-jsbasic-timercomponennenttvuedragdropuploadimages@apato/tupelo-wasm-sdkgolos-classic-dev-jsgolos-classic-js-devkuknos-sdknext-i18next-url@quantumart/qp8-page-structurepops-app-sstvpops-kids-sstvpops-plus-webbb-chat@everreal/er-common-helpers@frxf/frxf@next-zero/framework@kichiyaki/next-i18next@texttree/demo-bsa-reference-rcl@monid/did-registryeuphoric-adventures-sdk@l1nyanm1ng/react-picture-viewercaizchain-sdksteem-engine-jscthpb-plugin-socialmusescore-dl@peopledata/peopledata-did-registrylevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29@cloudhub-ux/core@creativebinary/cbsteem-jsone-index@yeep/clientcclibyarntesthyperpass-sdknoir-jssklif-ui-kitsklif-api@everything-registry/sub-chunk-1471p149-tablesklif-uitaman-baca-masyarakattasegirtbag-enginetest-carosello-campuswlsjswlsjs-stagingwisperjsvue-button-test1webdatabasetest1webdatabasetest10webcryptowebdesa-laravel-final-releasewebpack_component_fundwehelpjsxdb-digitalbits-sdkteapackage-tatespoorman297telegram-mtprotosublime-corestories-fsstore.pouchdbstack-corestackfiretestweblibapitestgamebankviz-world-jsviz-js-libvue-compmentvit-jsvisualdlvcloudcam-playkit-js-hlsvoilk@donation-alerts/common@donation-alerts/events@creativechain-fdn/crea-js@cryptolize/core@cryptolize/persistence@crds_npm/crds-components@cs-museum/api@cube-design/react@conjecto/next-i18next@digitalbits-blockchain/js-stellar-sdk@digitalbits-blockchain/xdb-digitalbits-sdk@digitalfans/zipcodes@boone-development/morphene-js@blinknetwork/sdk@beldore/react-otp-input@rbc-public/react-selectable-fastcustom-react-app1custom-react-app2ivanm-js-stellar-sdkitemjs
2.1.0

4 years ago

2.0.5

4 years ago

2.0.4

7 years ago

2.0.3

11 years ago

2.0.2

11 years ago

2.0.1

11 years ago

2.0.0

11 years ago

1.0.0

11 years ago