title: Express Session: Object #<Object> has no method 'on'
body: <p>I'm using ExpressJS and have been trying to get PassportJS working. In my <code>express.js</code> config, I have the following:</p>
  
  <pre><code>app.configure(function () {
          // dynamic helpers
          app.use(helpers(config.app.name));
  
          // cookieParser should be above session
          app.use(express.cookieParser());
  
          // bodyParser should be above methodOverride
          app.use(express.bodyParser());
          app.use(express.methodOverride());
  
          // express/mongo session storage
          app.use(express.session({
            secret: 'noobjs',
            store: new mongoStore({
              url: config.db,
              collection : 'sessions'
            })
          }));
  
          // connect flash for flash messages
          app.use(flash());
  
          // use passport session
          app.use(passport.initialize());
          app.use(passport.session());
  
  ...
  </code></pre>
  
  <p>Unfortunately, I get the following error when I run the app:-</p>
  
  <pre><code>store.on('disconnect', function(){ storeReady = false; });
  ^
  TypeError: Object #&lt;Object&gt; has no method 'on'
  </code></pre>
  
  <p>I think it has something to do with initialization order, but am too inexperienced around express to know what the order should be.</p>
  
  <p>Can anyone offer some direction please?</p>