Rookie
Rookie

Reputation: 939

Module '"redis"' has no exported member 'RedisClient'

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?

Upvotes: 7

Views: 7365

Answers (2)

Rookie
Rookie

Reputation: 939

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` });

Upvotes: 1

FRoBa
FRoBa

Reputation: 31

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

Upvotes: 3

Related Questions