NodeJS: Can't start connect-redis with Express 4.12.2

I am using express 4.12.2, express-session 1.11.1 and connect-redis 1.4.7. When running the following code with NODE_ENV=production npm start

:

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

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

      

I am getting the following error:

 var Store = connect.session.Store;
                            ^
 TypeError: Cannot read property 'Store' of undefined

      

Any help would be greatly appreciated.

+3


source to share


1 answer


1.4.7

is a rather old version connect-redis

. Since this version, the signature has changed. Before it accepts an object connect

, but after update 2.0 with expression 4, it now accepts an object session

. Your code is already using the new signature, so for that all you have to do is update yourpackage.json

...
"dependencies": {
    ...
    "connect-redis": "^2.3.0"
}
...

      



and / or update the module in place:

npm install connect-redis

      

+1


source







All Articles