diff --git a/lib/loglevel.js b/lib/loglevel.js
index <HASH>..<HASH> 100644
--- a/lib/loglevel.js
+++ b/lib/loglevel.js
@@ -19,7 +19,7 @@
     // Slightly dubious tricks to cut down minimized file size
     var noop = function() {};
     var undefinedType = "undefined";
-    var isIE = (
+    var isIE = (typeof window !== undefinedType) && (
         window.navigator.userAgent.indexOf('Trident/') >= 0 ||
         window.navigator.userAgent.indexOf('MSIE ') >= 0
     );
Fix bug in IE test that breaks logging for node.js