我的应用程序在我的Cloud9工作区上运行正常但在Heroku上运行不正常。 我连接到mLab数据库。 我也尝试过切换数据库,但它不起作用。
它抛出此错误
nandkishor8878:~/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.
答案 0 :(得分:0)
请参见this related question。看来您正在尝试将Express会话存储与猫鼬一起使用,所以我猜您正在使用connect-mongo。确保您没有在store
呼叫中键入express.session()
属性。
我还建议您检出connect-mongodb-session作为connect-mongo的替代方法。开箱即用更容易,更不容易出错。