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;