title: TypeError: MongoStore is not a Constructor
body: <p>I am making a website with google authentication. I try to store my session in my mongodb database. But when I add the store option to my express session, it keeps giving the following error.</p>
  <pre><code>TypeError: MongoStore is not a constructor
  at Object.&lt;anonymous&gt; (C:\Users\HP\Desktop\Website\animetography\mongodb\app.js:42:12)
  at Module._compile (internal/modules/cjs/loader.js:1137:30)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
  at Module.load (internal/modules/cjs/loader.js:985:32)
  at Function.Module._load (internal/modules/cjs/loader.js:878:14)
  at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
  at internal/main/run_main_module.js:17:47
  </code></pre>
  <p>My app.js code is as follows:</p>
  <pre><code>const express = require('express');
  const mongoose = require('mongoose');
  const dotenv = require('dotenv');
  const morgan = require('morgan');
  const exphbs = require('express-handlebars');
  const methodOverride = require('method-override');
  const passport = require('passport');
  const session = require('express-session');
  const MongoStore = require('connect-mongo');(session);
  const connectDB = require('./config/db');
  
  //Load Config
  
  dotenv.config({path: './config/config.env'});
  
  //Passport Config
  require('./config/passport')(passport);
  
  
  connectDB();
  
  const app = express();
  
  //Logging
  if(process.env.NODE_ENV === 'development') {
      app.use('morgan'('dev'));
  }
  
  //Handebars
  
  app.engine('.hbs', exphbs({defaultLayout: 'main', extname: '.hbs'}));
  app.set('view engine', '.hbs');
  
  // Express Sessions
  
  app.use(
    session({
      secret: 'keyboard cat',
      resave: false,
      saveUninitialized: false,
      store: new MongoStore({ mongooseConnection: mongoose.connection }),
    })
  );
  
  // Passport Middleware
  
  app.use(passport.initialize());
  app.use(passport.session());
  
  //Static folder
  
  app.use(express.static(path.join(__dirname, 'public')));
  
  
  //ROUTES
  app.use('/', require('./routes/index'));
  app.use('/auth', require('./routes/auth'));
  
  const port = process.env.PORT || 3000
  
  
  app.listen(port,
      console.log(`Server Running in ${process.env.NODE_ENV} mode on port ${port}`)
      );
  </code></pre>
  <p>The error occurs at:</p>
  <pre><code>store: new MongoStore({ mongooseConnection: mongoose.connection }),
  </code></pre>
  <p>Can someone tell me what I'm doing wrong? I can't figure out why this error is occurring.</p>