TypeError: this.client.set is not a function

来源:10-9 session连接redis

顾鸟

2021-09-23

(node:8060) UnhandledPromiseRejectionWarning: TypeError: this.client.set is not a function
at RedisStore.set (E:\own\nodejs-learning\blog-express\node_modules\connect-redis\lib\connect-redis.js:65:21)
at Session.save (E:\own\nodejs-learning\blog-express\node_modules\express-session\session\session.js:72:25)
at Session.save (E:\own\nodejs-learning\blog-express\node_modules\express-session\index.js:406:15)
at ServerResponse.end (E:\own\nodejs-learning\blog-express\node_modules\express-session\index.js:335:21)
at ServerResponse.send (E:\own\nodejs-learning\blog-express\node_modules\express\lib\response.js:221:10)
at ServerResponse.json (E:\own\nodejs-learning\blog-express\node_modules\express\lib\response.js:267:15)
at result.then (E:\own\nodejs-learning\blog-express\routes\blog.js:28:9)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
(node:8060) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8060) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

双越老师,请问这个问题该怎么解决?

写回答

2回答

双越

2021-09-23

redis 连接有问题。

你单独写一个 redis 连接的 demo ,看是否能正常运行?

0
2
双越
回复
顾鸟
好的。
2021-09-23
共2条回复

顾鸟

提问者

2021-09-23

redis.js

module.exports = {

  redisClient,

};

app.js

const { redisClient } = require("./db/redis");

注意

commonjs的语法


0
0

Node.js+Express+Koa2+Nest.js 开发服务端

从入门到实战,一站式掌握 Node.js+Express+Koa2

4103 学习 · 2021 问题

查看课程