2.1.0 • Published 4 months ago

detect-node v2.1.0

Weekly downloads
8,766,083
License
MIT
Repository
github
Last release
4 months 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-transportvuedragdropuploadimages@apato/tupelo-wasm-sdkgolos-classic-dev-jsgolos-classic-js-devkuknos-sdknext-i18next-urlmetamask-crx@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-sdkmjml-coremjml-core-node6mncss@cloudhub-ux/coreviz-world-jsviz-js-libmuseblockchain-jsvue-compmentvii-sdkvoilkvisualdlvit-js@pollyjs/adapter-fetchmusescore-downloader@dreamcatcher-tech/dos@flowfact/api-services@microdrop/helpers@generative-music/samples.generative.fm@metabin/share@micropede/client@galtproject/libp2p-interfaces@michaelmure/ipfs-apiwehelpjs@rbc-public/react-selectable-fastwisperjsnotabugnois-react-toastnpci-payment-xdr-sdk@react-keycloak/nextjs@react-keycloak/razzle@react-keycloak/ssrwlsjswlsjs-stagingnode-red-contrib-ipfsapi@relaxjs/core@redstarnv/next-i18next@sanity/document-windownoise-canvasnode-red-ipfstestxdb-digitalbits-sdkmjml-parser-xmlmjml-parser-xml-node6@open-rpc/schema-utils-jsmodified-stellar-sdkvcloudcam-playkit-js-hlsnetsapiens.jsneptune-namespaces-runtimenext-i18next-serverlessnext-i18next-waresixnext-i18next2.0next-i18next_express-typesnext-lang-routesnio-iso-utilsnio-tools@quantumart/qa-engine-page-structure@visualdl/i18n@virtualpatterns/mablungnextjs-i18n-ie11next-shopify-storefrontwebcryptoopensubtitles-universal-apiarborisart-build-configuratorarwesattheme-editor-apiopen-rpc-utilsappcenter-file-upload-client@conjecto/next-i18next@symblai/symbl-js@steemit/steem-jsart-standard-libart-validator@m-ld/m-ldtest-carosello-campustelegram-mtproto@lerayne/redux-ssr@lit-protocol/libp2p-webrtc-direct@factor/cloud-config@factor/toolstestgamebank
2.1.0

4 months ago

2.0.5

6 months ago

2.0.4

3 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.0

7 years ago