Closed fanatid closed 7 years ago
Read a bit about this today and it seems there is not a consensus on the best way to detect Node.js vs browser environment. Apparently browserify and webpack are the edge cases that create complications. I thought this discussion was good -- conclusion was that the "right" way to do this is:
typeof process !== "undefined" && process.nextTick && !process.browser
Well, process.nextTick
is defined if you require('process')
, but the browser does not normally have process.nextTick
(or process
) defined.
https://github.com/ethereumjs/keythereum/blob/0.4.7/index.js#L8-L11
NODE_JS
defined as(typeof module !== "undefined") && process && !process.browser
? not justprocess.browser
?var path = (NODE_JS) ? require("path") : null;
will better resolve throughbrowser
field inpackage.json