title: Node.js Mongoose trouble
body: <p>I'm trying to build my first REST-api but I keep getting this error with the mongoose module. </p>
  
  <p>The error message looks like this:</p>
  
  <pre><code>Josephs-MacBook-Pro:rest joseph$ node server
  API is running on port 3000
  
          /Users/joseph/Documents/Atom-files/rest/node_modules/mongoose/node_modules/mongodb/lib/server.js:228
                  process.nextTick(function() { throw err; })
                                                      ^
          Error
              at Object.&lt;anonymous&gt; (/Users/joseph/Documents/Atom-files/rest/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:42:24)
              at Module._compile (module.js:460:26)
              at Object.Module._extensions..js (module.js:478:10)
              at Module.load (module.js:355:32)
              at Function.Module._load (module.js:310:12)
              at Module.require (module.js:365:17)
              at require (module.js:384:17)
              at Object.&lt;anonymous&gt; (/Users/joseph/Documents/Atom-files/rest/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/index.js:2:17)
              at Module._compile (module.js:460:26)
              at Object.Module._extensions..js (module.js:478:10)
  </code></pre>
  
  <p>My server.js file looks like this:</p>
  
  <pre><code>var express = require('express');
  var mongoose = require('mongoose');
  var bodyParser = require('body-parser');
  
  mongoose.connect('mongodb://localhost/rest_test');
  
  var app = express();
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(bodyParser.json());
  
  app.use('/api', require('./routes/api'));
  
  
  
  app.listen(3000);
  console.log('API is running on port 3000');
  </code></pre>
  
  <p>And finally my api.js file looks like this:</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  
  
  router.get('/products', function(req,res){
    res.send('api is working');
  
  });
  
  
  module.exports = router;
  </code></pre>
  
  <p>I'm (obviously) new to developing in Node.js, and do not know why this error occurs. I know that <code>process.nextTick</code> has something to do with the node-loop, but I have no idea why the error would occur just as I start my application.</p>
  
  <p>Any suggestions would be appreciated.</p>