2016-09-19 12 views
-1

NodeアプリケーションをHerokuにデプロイするときに、次のエラーメッセージが表示されます。それを引き起こす原因は何か?NodeJs MongoDBとHeroku

  1. 2016-09-19T09:44:06.497018+00:00 app[web.1]: "stack": [
  2. 2016-09-19T09:44:06.497020+00:00 app[web.1]: "TypeError: options.mongooseConnection.once is not a function",
  3. 2016-09-19T09:44:06.497021+00:00 app[web.1]: " at MongoStore (/app/node_modules/connect-mongo/src/index.js:91:48)",
  4. 2016-09-19T09:44:06.497021+00:00 app[web.1]: " at Object. (/app/app/session/index.js:14:17)",
  5. 2016-09-19T09:44:06.497022+00:00 app[web.1]: " at Module._compile (module.js:413:34)",
  6. 2016-09-19T09:44:06.497022+00:00 app[web.1]: " at Object.Module._extensions..js (module.js:422:10)",
  7. 2016-09-19T09:44:06.497023+00:00 app[web.1]: " at Module.load (module.js:357:32)",
  8. 2016-09-19T09:44:06.497023+00:00 app[web.1]: " at Function.Module._load (module.js:314:12)",
  9. 2016-09-19T09:44:06.497024+00:00 app[web.1]: " at Module.require (module.js:367:17)",
  10. 2016-09-19T09:44:06.497024+00:00 app[web.1]: " at require (internal/module.js:20:19)",
  11. 2016-09-19T09:44:06.497025+00:00 app[web.1]: " at Object. (/app/app/index.js:16:15)",
  12. 2016-09-19T09:44:06.497025+00:00 app[web.1]: " at Module._compile (module.js:413:34)",
  13. 2016-09-19T09:44:06.497026+00:00 app[web.1]: " at Object.Module._extensions..js (module.js:422:10)",
  14. 2016-09-19T09:44:06.497027+00:00 app[web.1]: " at Module.load (module.js:357:32)",
  15. 2016-09-19T09:44:06.497027+00:00 app[web.1]: " at Function.Module._load (module.js:314:12)",
  16. 2016-09-19T09:44:06.497028+00:00 app[web.1]: " at Module.require (module.js:367:17)",
  17. 2016-09-19T09:44:06.497028+00:00 app[web.1]: " at require (internal/module.js:20:19)",
  18. 2016-09-19T09:44:06.497029+00:00 app[web.1]: " at Object. (/app/server.js:4:17)",
  19. 2016-09-19T09:44:06.497029+00:00 app[web.1]: " at Module._compile (module.js:413:34)",
  20. 2016-09-19T09:44:06.497030+00:00 app[web.1]: " at Object.Module._extensions..js (module.js:422:10)",
  21. 2016-09-19T09:44:06.497030+00:00 app[web.1]: " at Module.load (module.js:357:32)",
  22. 2016-09-19T09:44:06.497031+00:00 app[web.1]: " at Function.Module._load (module.js:314:12)",
  23. 2016-09-19T09:44:06.497032+00:00 app[web.1]: " at Function.Module.runMain (module.js:447:10)",
  24. 2016-09-19T09:44:06.497032+00:00 app[web.1]: " at startup (node.js:148:18)"
  25. 2016-09-19T09:44:06.497033+00:00 app[web.1]: ],
  26. 2016-09-19T09:44:06.497033+00:00 app[web.1]: "level": "error",
  27. 2016-09-19T09:44:06.497034+00:00 app[web.1]: "message": "uncaughtException: options.mongooseConnection.once is not a function"
  28. 2016-09-19T09:44:06.497035+00:00 app[web.1]: }
+1

createConnectionメソッドを使用する必要があり、あなたの 'mongoose'接続コードを入れることはできますか? – abdulbarik

答えて

0

私はあなたがこのエラーを得ている理由ですcreateConnection方法とconnectないとマングースの接続を作成していると思います。あなたがonceメソッドを使用したい場合は

.createConnection() returns a Connection instance.

.connect() returns the global mongoose instance.

は、その後、あなたは代わりにconnect方法

var db = mongoose.createConnection('MongoDB URL'); 
db.once('open', function() { ... });