最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Passport.js and MongoStore error "Connection strategy not found at MongoStore" - Stack Overflow

programmeradmin1浏览0评论

I am getting this strange error on my Node.js server:

 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._pile (module.js:425:26)

We are using Passport with Express.

The error is happening at the line mongoose_connection: mongoose.connection in the following snippet:

app.use(expressSession({
    secret: 'foobar',
    cookie: {
        secure: false,
        maxage: 1160000000,
        resave: true,
        saveUninitialized: true
    },
    store: new MongoStore({
        mongoose_connection: mongoose.connection   /*<== error happens here*/
    })
}));

What is this error and how can I fix it?

I am getting this strange error on my Node.js server:

 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._pile (module.js:425:26)

We are using Passport with Express.

The error is happening at the line mongoose_connection: mongoose.connection in the following snippet:

app.use(expressSession({
    secret: 'foobar',
    cookie: {
        secure: false,
        maxage: 1160000000,
        resave: true,
        saveUninitialized: true
    },
    store: new MongoStore({
        mongoose_connection: mongoose.connection   /*<== error happens here*/
    })
}));

What is this error and how can I fix it?

Share Improve this question edited Nov 29, 2016 at 19:57 Alexander Mills asked Dec 21, 2015 at 20:55 Alexander MillsAlexander Mills 100k166 gold badges537 silver badges916 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

According to docs, I believe that line should be:

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

Use mongooseConnection instead of mongoose_connection.

发布评论

评论列表(0)

  1. 暂无评论