Passport.js 和 MongoStore 错误 "Connection strategy not found at MongoStore"

Passport.js and MongoStore error "Connection strategy not found at MongoStore"

我的 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)

我们正在使用 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*/
    })
}));

这是什么错误,我该如何解决?

根据 docs,我认为该行应该是:

store: new MongoStore({
    mongooseConnection: mongoose.connection
});

使用 mongooseConnection 而不是 mongoose_connection