Files
reference/note/javascript/misc/check-if-the-code-is-running-in-node-js.md
T
2022-10-18 11:37:51 +08:00

437 B

title, tags, layout
title tags layout
How to check if the code is running in nodejs in JavaScript
JavaScript
one-line
js
note

In this Article we will go through how to check if the code is running in nodejs only using single line of code in JavaScript.

Let's define this short function:

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