skip to Main Content

I am creating a multi-node Express/Socket.io server using Typescript and I am trying to import RedisClient from redis, but I can’t get it to work because I get the error

Module ‘"redis"’ has no exported member ‘RedisClient’

It seems to be trying to retrieve it form

node_modules/redis/dist/index

But in reality it is here:

node_modules/@types/redis"

How can I get it to import from the right place?

2

Answers


  1. Chosen as BEST ANSWER

    After checking for some time I realized that things changed and the documentation states that you now do NOT need to use RedisClient. You now need to use:

    import { createClient } from "redis";
    

    This is what things look like now:

    const pubClient = createClient({ url: `redis://<path to redis>:6379` });
    

  2. Looks like Redis package has been officially updated to v4 recently, which introduced some breaking changes, including several interface changes.

    I recommend to temporarily use the v3 until all your dependencies (including @types/redis) are properly updated:

    npm install redis@3
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search