【发布时间】:2017-12-04 21:03:14
【问题描述】:
我正在关注 Heroku 上的 tutorial 构建一个 MEAN Stack Contact APP,但我遇到了一些奇怪的错误!虽然我的应用程序在部署后运行良好,但当我在本地运行该应用程序时无法连接到 Mongodb。我得到的错误是:
url.js:88 throw new TypeError('Parameter "url" 必须是字符串,而不是' + typeof url);
^TypeError: 参数“url”必须是字符串,不是未定义的
在 Url.parse (url.js:88:11)
在 Object.urlParse [解析] (url.js:82:5)
在 module.exports (/Users/Ananda/mean-contactlist/node_modules/mongodb/lib/url_parser.js:15:23)
在连接时 (/Users/Ananda/mean-contactlist/node_modules/mongodb/lib/mongo_client.js:480:16)
在 Function.MongoClient.connect (/Users/Ananda/mean-contactlist/node_modules/mongodb/lib/mongo_client.js:244:3)
在对象。 (/Users/Ananda/mean-contactlist/server.js:17:21)
在 Module._compile (module.js:570:32)
在 Object.Module._extensions..js (module.js:579:10)
在 Module.load (module.js:487:32)
在 tryModuleLoad (module.js:446:12)
根据我的理解,当我使用“节点服务器”启动应用程序时,它找不到 mongodb 数据库 url ...只是不知道为什么,因为它在 heroku 上运行时发现它很好。我还能做些什么来在本地运行这个应用程序?他们在Github 上有完整的应用程序。我也克隆了它并尝试在本地运行它并收到错误。为什么它在部署时工作但在本地不工作?
【问题讨论】:
标签: angularjs node.js mongodb heroku mean-stack