NodeJS: I can't make connect-redis work with express

Cherif picture Cherif · Mar 10, 2014 · Viewed 7.2k times · Source

This is my code :

var express = require('express');
var RedisStore = require('connect-redis')(express);

And this is the error I get :

  RedisStore.prototype.__proto__ = Store.prototype;
                                        ^
TypeError: Cannot read property 'prototype' of undefined
    at module.exports (/home/cherif/Bureau/Twimbee/server/gamma/node_modules/connect-redis/lib/connect-redis.js:96:41)
    at Object.<anonymous> (/home/cherif/Bureau/Twimbee/server/gamma/index.js:2:42)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3

Please help

Answer

Matt Pileggi picture Matt Pileggi · Mar 10, 2014

Looks like they've addressed this in their docs:

Due to express 4.x.x changes, we now need to pass express-session to the function connect-redis exports in order to extend express-session.Store:

var session = require('express-session') , RedisStore = require('connect-redis')(session);

app.use(session({ store: new RedisStore(options), secret: 'keyboard cat' }))

https://github.com/visionmedia/connect-redis under usage