Files
Vlad Durnea cffdf8af86
Some checks failed
CI/CD Pipeline / unit-tests (push) Failing after 1m16s
CI/CD Pipeline / integration-tests (push) Failing after 2m32s
CI/CD Pipeline / lint (push) Successful in 5m22s
CI/CD Pipeline / e2e-tests (push) Has been skipped
CI/CD Pipeline / build (push) Has been skipped
wip:milestone 0 fixes
2026-03-15 12:35:42 +02:00
..
2026-03-15 12:35:42 +02:00
2026-03-15 12:35:42 +02:00
2026-03-15 12:35:42 +02:00

Package version

is-node-process

Reliably determines if the code is running in Node.js

Motivation

This library was created to provide a reliable way of determining a Node.js process, taking into account:

  • Browser-like environments (JSDOM);
  • Electron renderer process;
  • React Native runtime.

Why relying on window is a bad idea

There are environments (i.e. JSDOM) that polyfill the global window object and some of its API for the sake of emulating browser-like behaviors, while still remaining a Node.js process.

Why relying on process is a bad idea

Electron injects a global process object in the browser runtime when run with the nodeIntegration: true option.

Getting started

$ npm install is-node-process
# or
$ yarn add is-node-process
// any/code.js
const { isNodeProcess } = require('is-node-process')
isNodeProcess() // true/false