Check for existence of module before using module.exports

Not all environments define the global variable _module_. Verify that it exists before using it