check for existence of module before setting to it, when running in node; fixes #2586