properly check for Node.js module object so browser does not throw an error