我在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.(/Users/amills001c/WebstormProjects/lectal_all/manager/app.js:42:12) at Module._compile (module.js:425:26)
我们正在使用Passport和Express.
错误发生在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*/ }) }));
这是什么错误,我该如何解决?
根据文档,我认为该行应该是:
store: new MongoStore({ mongooseConnection: mongoose.connection });
用mongooseConnection
而不是mongoose_connection
.