0

Basically, there are two things that could happen if you run a .js file. It can either be run with Windows Script Host, or with Node.js.

In the .js file itself, I need to know what is being used to run the script, and then run different code depending on that.

How do I do that, if that is even possible?

Taureon
  • 75
  • 1
  • 9
  • https://stackoverflow.com/questions/34550890/how-to-detect-if-script-is-running-in-browser-or-in-node-js/48536927 – Rani Sharim Oct 15 '21 at 20:12
  • @RaniSharim first I was gonna say "jscript aint browser tho" but the answer in that question makes sense so thank you – Taureon Oct 15 '21 at 20:18

1 Answers1

0

require.main === module returns true if the script is executed directly with node. Otherwise, it returns false.