Does if(root && root.console && root.console.log) check work in node and rhino? I seem to remember running into issues either in rhino or node where root was undefined and if(root) was breaking and if(typeof root !== 'undefined') worked just fine.