我在Node.js服务器上收到这个奇怪的错误:
Error: Connection strategy not found at MongoStore (/Users/amills001c/WebstormProjects/lectal_all/manager/node_modules/connect-mongo/src/index.js:100:23) at Object.<anonymous> (/Users/amills001c/WebstormProjects/lectal_all/manager/app.js:42:12) at Module._compile (module.js:425:26)
我们正在使用带Express的Passport。
错误发生在以下代码段中的mongoose_connection: mongoose.connection
行:
app.use(expressSession({
secret: 'foobar',
cookie: {
secure: false,
maxage: 1160000000,
resave: true,
saveUninitialized: true
},
store: new MongoStore({
mongoose_connection: mongoose.connection /*<== error happens here*/
})
}));
这是什么错误,我该如何解决?
答案 0 :(得分:8)
根据docs,我认为该行应该是:
store: new MongoStore({
mongooseConnection: mongoose.connection
});
使用mongooseConnection
代替mongoose_connection
。