2

I'm new to Sails/Node.js, so please be patient :)

I'm trying to set up Sails 0.11.3 to work with google auth via Passport. It worked quite well (google auth worked) until I tried to enable mongo session storage.

Once I've added into config/session.js:

  adapter: 'mongo',
  host: 'localhost',
  port: 27017,
  db: 'xxxx', //REAL_DB_NAME_HERE
  collection: 'sessions',

sails lift refuses to start the server:

$ 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 is installed and recent.

Any ideas how to cure this? Thanks in advance!

2 Answers2

3

Try to install connect-mongo@0.8.2

derzunov
  • 452
  • 4
  • 13
-1

1) install npms

npm install --save connect-mongo@0.8.2 lodash

2) enable

_: true,

at config/globals.js

broderix
  • 385
  • 4
  • 9