2.1.0 • Published 3 years ago

detect-node v2.1.0

Weekly downloads
8,766,083
License
MIT
Repository
github
Last release
3 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-1471@314oner_npm/universal-components-libraryp149-tablesklif-uinpci-payment-xdr-sdkzog@galtproject/libp2p-interfaceszubtesttoday@generative-music/samples.generative.fm@geesmart/zxlibyyvip-art-templatezagg-stellar-sdk@gnexcoin/gnex-js@gnexcoin/gnexjs@helcor/window-sizes@globalfishingwatch/gdal3.js@hamzamahmood/axios-client-adapter@lozzychops/dropdown-menu@marinaga/bananizenextjs-stories@imdreamrunner/next-i18next-koa-async@lumeweb/libethsync@lumeweb/libportal@lumeweb/libs5@junvary/quasar-ui-qcascader@juanaraneta/dept-central-lib-client@knooks/use-title@knowledgr/knowledgr-js@kristoffertonning/vue-laravel-errors@l1/b3@laodabi/0x-utils@lerayne/redux-ssrfangkuaifastlion-picture-viewer@leiyulf/gantt-task-reactff-api-services@lit-protocol/libp2p-webrtc-direct@hiveio/hive-js@hivechain/hivejs@hivechain/steem-jsgolosgolos-classic-jsgolos-jsgolos-lib-js@nrl-demo/knowledgr-js@nsshunt/stsinstrumentation@nsshunt/stsmodels@nsshunt/stsoauth2plugin@nsshunt/stsobservability@nsshunt/stspublisherserver@nsshunt/stssocketio-clientgamebank@montmirail/next-i18next@ocario/ipfs-http-client
2.1.0

3 years ago

2.0.5

3 years ago

2.0.4

6 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.0

10 years ago