555 B
555 B
title, type, tags, cover, dateModified
| title | type | tags | cover | dateModified | |
|---|---|---|---|---|---|
| Environment is Node.js | snippet |
|
cloudy-rock-formation | 2021-04-02T11:45:13+03:00 |
Determines if the current runtime environment is Node.js.
- Use the
processglobal object that provides information about the current Node.js process. - Check if
process,process.versionsandprocess.versions.nodeare defined.
const isNode = () =>
typeof process !== 'undefined' &&
!!process.versions &&
!!process.versions.node;
isNode(); // true (Node)
isNode(); // false (browser)