Error: Connection strategy not found MongoDB
Add URL to new MongoStore()
var sessionStore = new MongoStore({ host: '127.0.0.1', port: '27017', db: 'session', url: 'mongodb://localhost:27017/demo' });
The code in the question is from the book Beginning Node.js by Basarat Ali Syed.
Since you're using a session collection so it should be like this
app.use(expressSession({ store: new mongoStore({ mongooseConnection: mongoose.connection, collection: 'session', }) }));
You need to define a database connection and then pass it to the new MongoStore. The 'db:' parameter you are using is expecting a MongoDB driver connect, not a url to a Mongo Database. For that, you should do something like this:
var sessionStore = new MongoStore({ url:'mongodb://localhost:27017/test');
Here's an example I know works, although it uses Mongoose instead of the MongoDB driver.
var mongoose = require('mongoose');mongoose.connect('mongodb://localhost:27017/test');var sessionStore = new MongoStore({mongooseConnection: mongoose.connection });