ITADN

Example does not work

#424Closedjackofsometrade 创建于 2025-03-08
J
jackofsometradecommented
If you copy the example, any calls to redis break with "**client.get is not a function**". It appears that the current version of the `redis` package creates a `Commander` object for the client, which has no method `get`. The issue exists between `connect-redis` `8.0.1` and `redis` `4.7.0`. Steps to reproduce: `npm install redis connect-redis` Use the example to enable redis session storage: ```import {RedisStore} from "connect-redis" import session from "express-session" import {createClient} from "redis" // Initialize client. let redisClient = createClient() redisClient.connect().catch(console.error) // Initialize store. let redisStore = new RedisStore({ client: redisClient, prefix: "myapp:", }) // Initialize session storage. app.use( session({ store: redisStore, resave: false, // required: force lightweight session keep alive (touch) saveUninitialized: false, // recommended: only save session when data exists secret: "keyboard cat", }), ) ``` Observe the error: ``` TypeError: client.get is not a function at Object.get (/project/node_modules/connect-redis/dist/connect-redis.cjs:28:28) at RedisStore.get (/project/node_modules/connect-redis/dist/connect-redis.cjs:55:36) at session (/project/node_modules/express-session/index.js:493:11) ``` It breaks on line 53 of index.ts: ```get: (key) => client.get(key),```
关闭于 2025-03-10 4 条评论