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:workWebStorm11in unnerw.exe C:work odejs_v4_4_4 ode.exe binwww
c:UsersAdministratorWebstormProjectslog ode_modulesconnect-mongosrcindex.js:105
                throw new Error('Connection strategy not found');
                ^

Error: Connection strategy not found
    at MongoStore (c:UsersAdministratorWebstormProjectslog ode_modulesconnect-mongosrcindex.js:105:23)
    at Object.<anonymous> (c:UsersAdministratorWebstormProjectslogapp.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:UsersAdministratorWebstormProjectsloginwww: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
})

原文地址:https://www.cnblogs.com/zaifeng0108/p/7225047.html