0

I'm trying to use connect-redis and express-session for session management and I'm getting an error when passing in my Redis client.

Here is the code:

const app = express();

const RedisStore = connectRedis(session);
let redisClient = redis.createClient({ legacyMode: true });
redisClient.connect().catch(console.error);

app.use(
  session({
    store: new RedisStore({
      client: redisClient,
      disableTouch: true,
    }),
    cookie: {
    maxAge: 10000000000,
      httpOnly: true,
      secure: false
    },
    saveUninitialized: false,
    secret: 'keyboard cat',
    resave: false,
  })
)

I'm following the guide posted here. Thanks!

Trentwt
  • 15
  • 6

1 Answers1

1

You probably imported types from the package @types/redis. Looking at its Yarn page, we see that @types/redis is now deprecated with this note:

redis provides its own type definitions, so you don't need @types/redis installed!

The latest version of the package is 4.0.11, released on Dec 9, 2021. I'm guessing the error arises from the differences between this package and newer versions of the package redis.

To remove the package @types/redis, you can run $ yarn remove @types/redis.

I had a similar error and that stopped VS Code from complaining.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
vls9
  • 113
  • 10