我是Sails / Node.js的新手,所以请耐心等待:)
我正在尝试设置Sails 0.11.3以通过Passport使用google auth。它工作得很好(google auth工作),直到我尝试启用mongo会话存储。
一旦我添加到config / session.js:
adapter: 'mongo',
host: 'localhost',
port: 27017,
db: 'xxxx', //REAL_DB_NAME_HERE
collection: 'sessions',
sails lift拒绝启动服务器:
$ sails lift
info: Starting app...
error: A hook (`session`) failed to load!
error: Could not load Connect session adapter :: connect-mongo
Error from adapter:
TypeError: Object function lodash(value) {
// exit early if already wrapped
if (value && value.__wrapped__) {
return value;
}
// allow invoking `lodash` without the `new` operator
if (!(this instanceof lodash)) {
return new lodash(value);
}
this.__wrapped__ = value;
} has no method 'assign'
at new MongoStore (/Users/dennis/Projects/Node.js/rubysails/node_modules/connect-mongo/lib/connect-mongo.js:114:19)
at Hook.SessionHook.initialize (/usr/local/lib/node_modules/sails/lib/hooks/session/index.js:169:37)
at Hook.bound [as initialize] (/usr/local/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at /usr/local/lib/node_modules/sails/lib/hooks/index.js:74:14
at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:451:17
at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:441:17
at _each (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Object.taskComplete (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:440:13)
at processImmediate [as _immediateCallback] (timers.js:345:15)
Do you have the Connect session adapter installed in this project?
Try running the following command in your project's root directory:
npm install connect-mongo
(Note: Make sure the version of the Connect adapter you install is compatible with Express 3/Sails v0.10)
connect-mongo已安装且最近安装。
任何想法如何治愈这个?提前谢谢!
答案 0 :(得分:3)
尝试安装connect-mongo@0.8.2
答案 1 :(得分:-1)
1)安装npms
npm install --save connect-mongo@0.8.2 lodash
2)启用
_: true,
在config / globals.js