Make module work in node environments where `window` global is defined

I submitted this previously from my master. This is the same PR, but from a branch so I can keep it isolated from other changes I need to make on master.

Previously, having `window` defined in the global context made this
module behave as if wasn't running in node. I am attempting to use it
in a node environment where there is also a global window object, so
the nature of the check is causing problems. This commit changes the
check… it tries to determine if we're running in Node (instead of if
we're *not* running in Node) by looking for the `process.versions`
hash. It also always tries to use require if it exists, rather than
skipping it if we have a window defined.