[Home] > Snippets  > Languages  > JavaScript  > Misc  >  Check if the code is running in NodeJS

Check if the code is running in NodeJS

JavaScript

const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null

TypeScript

const isNode: boolean = typeof process !== 'undefined' && process.versions != null && process.versions.node != null