How do I tell the difference between webworker and a node environment? Neither of them have a window
. They appear similar as a result.
if(module) console.log("node");
As far as i know, web workers don't have modules. There are probably a lot of other globals that are only available in node, require
for example, or __dirname
, here is a complete list.