求助: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回答
-
先不用管是不是标红。运行一下,登录,看看是不是会报错。
042020-03-27
相似问题