Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

detect-node

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Issues
File Explorer

Advanced tools

detect-node

Detect Node.JS (as opposite to browser environment) (reliable)

    2.1.0latest

Version published
Maintainers
1
Weekly downloads
12,450,207
decreased by-13.65%

Weekly downloads

Readme

Source

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.

Keywords

FAQs

What is detect-node?

Detect Node.JS (as opposite to browser environment) (reliable)

Is detect-node popular?

The npm package detect-node receives a total of 9,989,030 weekly downloads. As such, detect-node popularity was classified as popular.

Is detect-node well maintained?

We found that detect-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 16 May 2021

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc