title: 'process.nextTick(function() { throw err; })' - Undefined is not a function (mongodb/mongoose)
body: <p>I'm trying to connect to my <strong>mongodb</strong> using nodejs and socket.io. I am able to connect to the database because I get 'connection accepted' in my console but on the nodejs side, as soon as I - indeed - get </p>
  
  <blockquote>
    <p>Connection to mongodb://localhost:27017 established through mongoose</p>
  </blockquote>
  
  <p>it immediately fails next with </p>
  
  <blockquote>
    <p>process.nextTick(function() { throw err; }) ^TypeError: undefined is
    not a function at showCollections**</p>
  </blockquote>
  
  <p>And here goes showCollections:</p>
  
  <pre><code>var showCollections = function(db, callback) { 
      mongoose.connection.db.collectionNames(function(error, names) {
      if (error) {
        throw new Error(error);
      } else {
          console.log("=&gt;Listening mongo collections:");
        names.map(function(cname) {
          mongoose.connection.db.dropCollection(cname.name);
          console.log("--»"+cname.name);
        });
      }
    });
  
  }
  </code></pre>
  
  <p>And here is the content of my database folder:</p>
  
  <pre><code>_tmp (empty folder)
  local.0
  local.ns
  mongod.lock
  </code></pre>
  
  <p>I run the mongodb by typing <strong>mongod --dbpath folder</strong> and it successfully 'awaits connections on port 27017'.</p>
  
  <p>Also, my node_modules from <strong>package.json</strong> (npm)</p>
  
  <pre><code>"dependencies": {
      "express": "^4.9.6",
      "socket.io": "latest",
      "mongodb": "~2.0",
      "mongoose": "*"
    }
  </code></pre>
  
  <p>Thank you very much for your help...</p>
  
  <p>StackTrace:</p>
  
  <pre><code>&gt; TypeError: undefined is not a function
  &gt;     at showCollections (/usr/share/nginx/www/index.js:77:25)
  &gt;     at NativeConnection.callback (/usr/share/nginx/www/index.js:46:3)
  &gt;     at NativeConnection.g (events.js:199:16)
  &gt;     at NativeConnection.emit (events.js:104:17)
  &gt;     at open (/usr/share/nginx/www/node_modules/mongoose/lib/connection.js:485:10)
  &gt;     at NativeConnection.Connection.onOpen (/usr/share/nginx/www/node_modules/mongoose/lib/connection.js:494:5)
  &gt;     at /usr/share/nginx/www/node_modules/mongoose/lib/connection.js:453:10
  &gt;     at /usr/share/nginx/www/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js:59:5
  &gt;     at /usr/share/nginx/www/node_modules/mongoose/node_modules/mongodb/lib/db.js:200:5
  &gt;     at connectHandler (/usr/share/nginx/www/node_modules/mongoose/node_modules/mongodb/lib/server.js:272:7)
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I'm as well having these problems when trying to run the nodejs instance:</p>
  
  <pre><code>{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
  js-bson: Failed to load c++ bson extension, using pure JS version
  </code></pre>
  
  <p>I tried fixing them as other questions here would tell but nothing worked either...</p>