“console” variable undefined inside require call

I’m facing a strange problem on Meteor and I can’t resolve it :

I’m developping a WebRTC app using Meteor, PeerJS and AdapterJS (which give an WebRTC plugin for unsupported browser like Safari or IE). These two libs are downloaded using NPM : meteor npm install peerjs/adapterjs

So in my view’s controller I have :

//import Peer from 'peerjs'; => same error with "import"
//import AdapterJS from 'adapterjs';
Template.view.onRendered(function(){

AdapterJS = require("adapterjs");
Peer = require("peerjs");
//var peerkey="..."
var peer = new Peer({
  key: peerkey,  // get a free key at http://peerjs.com/peerserver
  debug: 3,
  config: {'iceServers': [
    { url: 'stun:stun.l.google.com:19302' },
    { url: 'stun:stun1.l.google.com:19302' },
  ]}
});

But when I run my controller, I get an exception because “console” is undefined inside peerjs/util.js function when calling the peerjs constructor :

Uncaught TypeError: Cannot read property ‘log’ of undefined
Strangly, when I only require “peerjs”, there is no exeption… I tried to change the order of require functions but it won’t work. Other variable like “alert”, “window.console” work and are defined inside the module but “console” not… :confused:

Any suggestion can help ^^

Thanks in advance.

NB1: If I add a breakpoint on the first line of node_module/peerjs/lib/util.js, I see that the “console” variable is “undefined” inside util.js but … it is defined inside the caller function (fileEvaluate) !

NB2: I tried something else to check if the code inside adapterjs redefine or change something : I put ‘require(“adapterjs”)’ inside a timeout function with a long delay (10 seconds) and … console is still undefined inside peer module ! But when I comment require(“adapterjs”), no error, console is defined ! I think that Meteor do something special before running the controller script depending on require functions…

NB3: Here is a git repo to test the project : gitlab.com If you display the dev console, you will see exceptions.