我的应用程序在我的Cloud9工作区上运行得很好,但在Heroku上却不行。我连接到mLab数据库。我也尝试过切换数据库,但它不起作用。
错误日志:
hacker8878:~/workspace/YelpCamp/v10 (master) $ heroku run node app.js
Running node app.js on ⬢ murmuring-brushlands-13115... up, run.5176 (Free)
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
The YelpCamp server has started
(node:4) UnhandledPromiseRejectionWarning: Error: URL malformed, cannot be parsed
at module.exports (/app/node_modules/mongodb/lib/url_parser.js:17:21)
at connect (/app/node_modules/mongodb/lib/mongo_client.js:880:3)
at connectOp (/app/node_modules/mongodb/lib/mongo_client.js:269:3)
at executeOperation (/app/node_modules/mongodb/lib/utils.js:420:24)
at MongoClient.connect (/app/node_modules/mongodb/lib/mongo_client.js:260:10)
at Promise (/app/node_modules/mongoose/lib/connection.js:427:12)
at new Promise (<anonymous>)
at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:424:19)
at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:208:15)
at Object.<anonymous> (/app/app.js:19:10)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
(node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.发布于 2018-06-19 14:58:56
见这个相关的问题。看起来你在用猫鼬使用一个快速会话商店,所以我猜你使用的是连接-蒙戈。确保您没有在store调用中键入express.session()属性。
我还建议将连接-mongodb-会话作为连接-mongo的一种替代方式。开箱即用的工作更容易,出错的几率也较低。
https://stackoverflow.com/questions/50833382
复制相似问题