express 4.0 connect-mongo 运行时报错



app.use(session({
    secret: settings.cookieSecret,
    key: settings.db,//cookie name
    cookie: {maxAge: 1000 * 60 * 60 * 24 * 30},//30 days
    store: new MongoStore({
        //url: 'mongodb://localhost/db'
        db: settings.db,
        host: settings.host,
        port: settings.port
    })
}));


C:\work\WebStorm11\bin\runnerw.exe C:\work\nodejs_v4_4_4\node.exe bin\www
c:\Users\Administrator\WebstormProjects\blog\node_modules\connect-mongo\src\index.js:105
                throw new Error('Connection strategy not found');
                ^

Error: Connection strategy not found
    at MongoStore (c:\Users\Administrator\WebstormProjects\blog\node_modules\connect-mongo\src\index.js:105:23)
    at Object.<anonymous> (c:\Users\Administrator\WebstormProjects\blog\app.js:31:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (c:\Users\Administrator\WebstormProjects\blog\bin\www:7:11)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

Process finished with exit code 1


修改为

store: new MongoStore({
    url: 'mongodb://localhost/db'
    //db: settings.db,
    //host: settings.host,
    //port: settings.port
})

posted @ 2017-04-13 14:20  你的峰哥  阅读(242)  评论(0编辑  收藏  举报