求助:session用redis存时,store被标红,出现了错误

来源:10-11 登录中间件

yeyileng

2020-01-13

var express = require(‘express’)
var app = express()
const redis = require(‘redis’)
const session = require(‘express-session’)

const RedisStore = require(‘connect-redis’)(session)
const redisClient = redis.createClient()

app.use(
session({
store: new RedisStore({ client: redisClient }),
secret: ‘keyboard cat’,
resave: false
})
)

store被标红,出现了错误,并且redis不存储:
(property) session.SessionOptions.store?: session.Store | session.MemoryStore
不能将类型“RedisStore”分配给类型“Store | MemoryStore”。
Type ‘RedisStore’ is missing the following properties from type ‘Store’: regenerate, load, createSession, addListener, and 14 more.ts(2322)
index.d.ts(61, 5): The expected type comes from property ‘store’ which is declared here on type ‘SessionOptions’

弄了好长时间,没搞清楚

写回答

1回答

双越

2020-01-13

先不用管是不是标红。运行一下,登录,看看是不是会报错。

0
4
慕粉3643360
回复
yeyileng
换了啥版本,我的也不行
2020-03-27
共4条回复

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

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

4051 学习 · 2006 问题

查看课程