Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RedisStore - TypeError: Cannot read property 'prototype' of undefined

When I run the app I get that message. I am trying to follow the instructions described here

This is a portion of my app.js file

var express = require('express');
var RedisStore = require('connect-redis')(express); 
var redisStore = new RedisStore(); // setup redis
var flash = require('connect-flash');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var routes  = require('./routes')
like image 559
Guillermo Mansilla Avatar asked Mar 08 '14 18:03

Guillermo Mansilla


1 Answers

If you want to use Express 4.x

change from

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

to

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

Also remember to install express-session:

npm install express-session --save

If you plan to use Express 3.x, pick compatible version 1.4.7 of connect-redis to avoid the error.

 npm install [email protected] --save

To get more information about migrating Express 3 to version 4:

  • http://blog.avrora.io/2014/05/13/migration-from-express-3-x-to-4-0/
  • https://github.com/visionmedia/connect-redis#connect-redis
like image 127
Andrei Karpushonak Avatar answered Nov 15 '22 22:11

Andrei Karpushonak