0

I tried fixing the error as has been suggested in other SO answers, but I continue to get the error. Any ideas why?

I tried using the following fix from here: 'console' is undefined error for Internet Explorer and sticking it in a Meteor.startup in a client-side js file, but it didn't work.

Meteor.startup(function () {
  /**
   * Protect window.console method calls, e.g. console is not defined on IE
   * unless dev tools are open, and IE doesn't define console.debug
   */
  (function() {
    if (!window.console) {
      window.console = {};
    }
    // union of Chrome, FF, IE, and Safari console methods
    var m = [
      "log", "info", "warn", "error", "debug", "trace", "dir", "group",
      "groupCollapsed", "groupEnd", "time", "timeEnd", "profile", "profileEnd",
      "dirxml", "assert", "count", "markTimeline", "timeStamp", "clear"
    ];
    // define undefined methods as noops to prevent errors
    for (var i = 0; i < m.length; i++) {
      if (!window.console[m[i]]) {
        window.console[m[i]] = function() {};
      }    
    } 
  })();
});

Should I be sticking this code somewhere else?

Community
  • 1
  • 1
Eliezer Steinbock
  • 4,728
  • 5
  • 31
  • 43
  • why not do it outside of the `Meteor.startup`? So the package init code doesn't throw ReferenceError's? – imslavko Oct 14 '14 at 04:04

1 Answers1

0

Try placing the code outside the Meteor.startup() function. This has to execute before you call console.log anywhere.

Nicu Surdu
  • 8,172
  • 9
  • 68
  • 108