程式碼:
// 用mongoDb儲存會話資料
var MongoSessionStore = require('session-mongoose')(require('connect'));
var sessionStore = new MongoSessionStore({url: credentials.mongo.production.connectionString});
app.use(require('cookie-parser')(credentials.cookieSecret));
// store是会话存储的实例,默认为一个MemoryStore的实例
app.use(require('express-session')({ store: sessionStore }));
運行出現了一下錯誤
C:\Program Files\nodejs\projects\meadowlark\node_modules\session-mongoose\index.
js:266
})(connect.session.Store);
^
TypeError: Cannot read property 'Store' of undefined
at module.exports (C:\Program Files\nodejs\projects\meadowlark\node_modules\
session-mongoose\index.js:266:23)
at Object.<anonymous> (C:\Program Files\nodejs\projects\meadowlark\meadowlar
k.js:190:52)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3
我找了好久的百度和google,試過require('session-mongoose')(require('express'));等等,但還是失敗,也試過require('connect-mongo')( require('express'));,困惑了好久,特意向大佬們請問。
感謝! ###