2

我正在编写我的第二个MEAN应用程序。第一个是手动构建聚合组件(我不知道MEAN)并将其托管在 HEROKU;我尝试使用MONGOOSE,但由于与 HEROKU 的数据库连接出现问题而放弃了 - 它在我的 MAC 上运行良好。这一次它可以在我的 MAC 上运行,但我仍然遇到连接问题;我不想抛弃 MONGOOSE。在这一点上,我所拥有的只是基于其 zip 文件构建的 vanilla MEAN 应用程序,该 zip 文件是从MEAN Github 存储库下载的。有关我从 HEROKU 获得的日志,请参见下文:

2013-09-10T01:33:28.045816+00:00 heroku[web.1]: Starting process with command `grunt`
2013-09-10T01:33:29.526090+00:00 app[web.1]: Running "jshint:all" (jshint) task
2013-09-10T01:33:29.567534+00:00 app[web.1]: >> 1 file lint free.
2013-09-10T01:33:29.568809+00:00 app[web.1]: 
2013-09-10T01:33:29.568809+00:00 app[web.1]: Running "compass:dist" (compass) task
2013-09-10T01:33:29.573055+00:00 app[web.1]: Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.
2013-09-10T01:33:29.574527+00:00 app[web.1]: Warning: Cannot read property 'stdout' of undefined Used --force, continuing.
2013-09-10T01:33:29.574641+00:00 app[web.1]: 
2013-09-10T01:33:29.575774+00:00 app[web.1]: Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.
2013-09-10T01:33:29.574641+00:00 app[web.1]: Running "compass:dev" (compass) task
2013-09-10T01:33:29.576128+00:00 app[web.1]: Running "concurrent:target" (concurrent) task
2013-09-10T01:33:29.576043+00:00 app[web.1]: 
2013-09-10T01:33:30.414023+00:00 app[web.1]: Running "nodemon:dev" (nodemon) task
2013-09-10T01:33:30.511082+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] v0.7.10
2013-09-10T01:33:30.511537+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] to restart at any time, enter `rs`
2013-09-10T01:33:30.511664+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] watching: /app/config
2013-09-10T01:33:30.511664+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] watching: /app/app
2013-09-10T01:33:30.536018+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] Unable to write to temp directory. If you experience problems with file reloading, ensure /tmp is writable.
2013-09-10T01:33:30.550590+00:00 app[web.1]: debugger listening on port 5858
2013-09-10T01:33:30.578354+00:00 app[web.1]: Running "watch" task
2013-09-10T01:33:30.624330+00:00 app[web.1]: Waiting...10 Sep 01:33:30 - [nodemon] reading ignore list
2013-09-10T01:33:31.152639+00:00 app[web.1]:         throw er; // Unhandled 'error' event
2013-09-10T01:33:31.154862+00:00 app[web.1]:     at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
2013-09-10T01:33:31.148967+00:00 app[web.1]: Express app started on port 3000
2013-09-10T01:33:31.152143+00:00 app[web.1]: 
2013-09-10T01:33:31.152401+00:00 app[web.1]: events.js:72
2013-09-10T01:33:31.154862+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2013-09-10T01:33:31.154862+00:00 app[web.1]:     at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2013-09-10T01:33:31.154862+00:00 app[web.1]:     at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
2013-09-10T01:33:31.154862+00:00 app[web.1]:     at Socket.EventEmitter.emit (events.js:95:17)
2013-09-10T01:33:31.154862+00:00 app[web.1]:     at process._tickCallback (node.js:415:13)

任何对建议的评论都将受到欢迎。提前致谢。

4

1 回答 1

3

您需要在某处托管 MongoDB。有许多 MongoDB 托管服务,MongoHQ 和 MongoLab 最受欢迎。我使用 MongoHQ 取得了不错的效果,尽管我必须承认我并没有强调我的系统。您可以注册免费试用(我认为您获得了 512MB),完成后,将您的连接字符串替换为(注册时您将获得所有详细信息):

'mongodb://username:password@domain:port/dbName'

于 2013-09-10T05:26:54.363 回答