donpark / session-mongoose

`connect` Mongoose session store
72 stars 18 forks source link

Got a TypeError: connection.model is not a function #28

Open na57 opened 6 years ago

na57 commented 6 years ago

I've got a error:

> m-mall-admin@1.0.0 start /Users/na57/Documents/workshop/m-mall-admin
> babel-node ./bin/www

/Users/na57/Documents/workshop/m-mall-admin/node_modules/.0.5.2@session-mongoose/index.js:97
          this.model = connection.model(this.options.modelName, SessionSchema);
                                  ^

TypeError: connection.model is not a function
    at new SessionStore (/Users/na57/Documents/workshop/m-mall-admin/node_modules/.0.5.2@session-mongoose/index.js:97:35)
    at Object.<anonymous> (/Users/na57/Documents/workshop/m-mall-admin/app.js:26:22)
    at Module._compile (module.js:649:30)
    at loader (/Users/na57/Documents/workshop/m-mall-admin/node_modules/.6.26.0@babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/na57/Documents/workshop/m-mall-admin/node_modules/.6.26.0@babel-register/lib/node.js:154:7)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:501:12)
    at Function.Module._load (module.js:493:3)
    at Module.require (module.js:593:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/na57/Documents/workshop/m-mall-admin/bin/www:4:12)
    at Module._compile (module.js:649:30)
    at loader (/Users/na57/Documents/workshop/m-mall-admin/node_modules/.6.26.0@babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/na57/Documents/workshop/m-mall-admin/node_modules/.6.26.0@babel-register/lib/node.js:154:7)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:501:12)
    at Function.Module._load (module.js:493:3)
    at Function.Module.runMain (module.js:690:10)
    at /Users/na57/Documents/workshop/m-mall-admin/node_modules/.6.14.0@babel-cli/lib/_babel-node.js:151:24
    at Object.<anonymous> (/Users/na57/Documents/workshop/m-mall-admin/node_modules/.6.14.0@babel-cli/lib/_babel-node.js:152:7)
    at Module._compile (module.js:649:30)
    at Object.Module._extensions..js (module.js:660:10)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:501:12)
    at Function.Module._load (module.js:493:3)
    at Function.Module.runMain (module.js:690:10)
    at startup (bootstrap_node.js:194:16)
    at bootstrap_node.js:666:3

npm ERR! Darwin 17.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v9.8.0
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! m-mall-admin@1.0.0 start: `babel-node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the m-mall-admin@1.0.0 start script 'babel-node ./bin/www'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the m-mall-admin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     babel-node ./bin/www
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs m-mall-admin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls m-mall-admin
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/na57/Documents/workshop/m-mall-admin/npm-debug.log

How should I take this pls?

na57 commented 6 years ago

It will be correct, when I substitute mongoose.createConnection for mongoose.connect at index.js line 97. Is that a mistake?