Files
30-seconds-of-code/snippets/js/s/is-node.md
2023-05-07 16:07:29 +03:00

576 B

title, type, language, tags, cover, dateModified
title type language tags cover dateModified
Environment is Node.js snippet javascript
node
cloudy-rock-formation 2021-04-02T11:45:13+03:00

Determines if the current runtime environment is Node.js.

  • Use the process global object that provides information about the current Node.js process.
  • Check if process, process.versions and process.versions.node are defined.
const isNode = () =>
  typeof process !== 'undefined' &&
  !!process.versions &&
  !!process.versions.node;
isNode(); // true (Node)
isNode(); // false (browser)