is-platform-node This is a very simple script to detect if the current platform is node Using var isNode = require('is-platform-node'); if(isNode()){ //do something } // then it's the browser, or other platform Testing Run $ npm install Run $ npm test