首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >应用程序在本地环境中运行,但在Heroku上失败。

应用程序在本地环境中运行,但在Heroku上失败。
EN

Stack Overflow用户
提问于 2018-06-13 09:11:30
回答 1查看 418关注 0票数 0

我的应用程序在我的Cloud9工作区上运行得很好,但在Heroku上却不行。我连接到mLab数据库。我也尝试过切换数据库,但它不起作用。

错误日志:

代码语言:javascript
复制
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.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-19 14:58:56

这个相关的问题。看起来你在用猫鼬使用一个快速会话商店,所以我猜你使用的是连接-蒙戈。确保您没有在store调用中键入express.session()属性。

我还建议将连接-mongodb-会话作为连接-mongo的一种替代方式。开箱即用的工作更容易,出错的几率也较低。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50833382

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档