title: Node Js, Async Js, Listener must be a function
body: <p>Below is the output log of the code below that, I don't know why it is throwing the error, I'm think the numbers at the end of the lines are <code>line number</code>:<code>char number</code>, I'll post some key line numbers in with the code.</p>
  
  <blockquote>
    <p>for some reason not working<br>
    series complete</p>
    
    <p>events.js:171<br>
        throw TypeError('listener must be a function');<br>
              ^ TypeError: listener must be a function<br>
        at TypeError ()<br>
        at NativeConnection.EventEmitter.once (events.js:171:11)<br>
        at /home/melman/Documents/Git/angular-test/server.js:39:24<br>
        at /home/melman/Documents/Git/angular-test/node_modules/async/lib/async.js:5
    48:21<br>
        at /home/melman/Documents/Git/angular-test/node_modules/async/lib/async.js:2
    24:13<br>
        at iterate (/home/melman/Documents/Git/angular-test/node_modules/async/lib/a<br>
    sync.js:131:13)<br>
        at async.eachSeries (/home/melman/Documents/Git/angular-test/node_modules/as<br>
    ync/lib/async.js:147:9)<br>
        at _asyncMap (/home/melman/Documents/Git/angular-test/node_modules/async/lib<br>
    /async.js:223:9)<br>
        at Object.mapSeries (/home/melman/Documents/Git/angular-test/node_modules/as<br>
    ync/lib/async.js:213:23)<br>
        at Object.async.series (/home/melman/Documents/Git/angular-test/node_modules<br>
    /async/lib/async.js:546:19)<br></p>
  </blockquote>
  
  <pre><code>28: var serverConfiguration = {
      init: function (){
  30:       var self = this;
  
          async.series([
              function (callback) {
                  // connect to the db
                  db.connect('mongodb://localhost/piautomation');
  
                  var dbConn = db.connection;
                  dbConn.on('error', console.error.bind(console, 'connection error:'));
                  dbConn.once('open', callback(null));
  40:         },
              function (callback) {
                  console.log('Configure the db');
                  self.models = require('./server/config/mongoose')(db); // setup the db with the models and schemas
                  callback(null);
              },
              function (callback) {
                  console.log("Start creating models");
                  self.newsApi = require('./server/api/news')(self.models.News); // pass the news api the News model
                  callback(null);
  50:         },
              function (callback) {
                  console.log("configure routes");
                  require('./server/config/routes')(app, self.newsApi, clientDir, callback); // set up the routes with the model api's functions
              },
              function (callback) {
                  console.log("http server created");
                  var server = http.createServer(app);
                  console.log("starting reload");
                  reload(server, app);
  60:             console.log("start server listen");
                  // if we have successful db connection, allow the rest of the app to start up
                  server.listen(app.get('port'), function(){
                      console.log("Web server listening in %s on port %d", colors.red(process.env.NODE_ENV), app.get('port'));
                      callback(null);
                  });
                  console.log("for some reason not working");
                  callback(null);
              }
          ], function () {
  70:         console.log("series complete");
          });
      }
  }.init();
  </code></pre>