【问题标题】:Heroku App keeps crashing according to logs... why?Heroku App 根据日志不断崩溃……为什么?
【发布时间】:2013-05-01 10:06:52
【问题描述】:

一旦我部署了应用程序并推送了本教程中的代码: http://blog.superpat.com/2011/06/14/node-js-chat-demo-on-heroku/

我从 heroku 收到了这个错误: "应用程序发生错误,无法提供您的页面。请稍后重试。

如果您是应用程序所有者,请查看您的日志以获取详细信息。"

这是我得到的日志错误:

2013-05-07T12:46:21.537628+00:00 app[web.1]: module.js:340
2013-05-07T12:46:21.537946+00:00 app[web.1]:     throw err;
2013-05-07T12:46:21.538118+00:00 app[web.1]:           ^
2013-05-07T12:46:21.540143+00:00 app[web.1]: Error: Cannot find module 'pg'
2013-05-07T12:46:21.540143+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
2013-05-07T12:46:21.540143+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2013-05-07T12:46:21.540143+00:00 app[web.1]:     at require (module.js:380:17)
2013-05-07T12:46:21.540143+00:00 app[web.1]:     at Object.<anonymous> (/app/server.js:22:10)
2013-05-07T12:46:21.540143+00:00 app[web.1]:     at Module._compile (module.js:456:26)
2013-05-07T12:46:21.540143+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
2013-05-07T12:46:21.540143+00:00 app[web.1]:     at Module.load (module.js:356:32)
2013-05-07T12:46:21.540143+00:00 app[web.1]:     at Module.require (module.js:364:17)
2013-05-07T12:46:21.540462+00:00 app[web.1]:     at Function.Module.runMain (module.js:497:10)
2013-05-07T12:46:21.540143+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2013-05-07T12:46:22.755998+00:00 heroku[web.1]: Process exited with status 8
2013-05-07T12:47:21.212523+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=nodechatclient.herokuapp.com fwd="72.229.150.213" dyno= connect= service= status=503 bytes=
2013-05-07T12:47:22.593111+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=nodechatclient.herokuapp.com fwd="72.229.150.213" dyno= connect= service= status=503 bytes=

我遵循了该教程 github 中的所有代码。

可能是什么原因造成的?跟pg有关系吗?我应该在某处更改数据库路径吗?

当我尝试使用 node server.js 在本地运行它时,我得到了这个错误:

Error: Cannot find module    '/home/euridice/node_modules/pg/lib/native/../../build/default/binding'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/euridice/node_modules/pg/lib/native/index.js:16:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

这是什么意思?

编辑:修复了一些问题,现在我得到了:

events.js:72
    throw er; // Unhandled 'error' event
          ^
Error: FATAL:  password authentication failed for user "postgres"
FATAL:  password authentication failed for user "postgres"

at Connection.<anonymous>    (/home/euridice/node_chat/node_modules/pg/lib/native/index.js:187:17)
at Connection.EventEmitter.emit (events.js:95:17)

【问题讨论】:

  • 这闻起来就像你的应用程序中没有安装 PG 模块作为依赖项。
  • 持久性作为后续步骤添加到聊天服务器。您是否在 package.json 文件中添加了 postgres 作为依赖项?稍后在原始博客文章中有一个如何执行此操作的示例,尽管我建议对 postgres 使用 1.1.0 版本(而不是博客文章中给出的 0.5 版本)。谢谢
  • @JR0cket,不,我没有。我想我会留意的。请参阅我的编辑。在哪里可以找到将 postgres 添加为依赖项的说明?我找不到它。
  • 实际上,它说:“在 nodechatclient 上添加共享数据库...失败!找不到插件。”

标签: node.js postgresql heroku crash


【解决方案1】:

运行

npm install

本地,并将“node_modules”文件夹推送到heroku

编辑: 我认为您误解了一些 git 和 herkoku 概念。你需要:

1. clone the repository: 'git clone git://github.com/metadaddy-sfdc/node_chat.git'
2. go into the repository: 'cd node_chat'
3. now you can run 'npm install' in THAT folder
4. after that you can create your heroku app: 'heroku create'
5. and deploy that to heroku: 
  5.1 git add .
  5.2 git commit -m "some comment"
  5.3 git push heroku master

您必须 a) 在您的 node_chat 文件夹中,b) 首先安装 npm,然后将所有内容 (git add .) 推送到 heroku!

【讨论】:

  • "npm ERR!安装无法读取依赖项 npm ERR!错误:ENOENT,打开 '/home/euridice/package.json' npm ERR!如果您需要帮助,可以在以下位置报告此日志: npm ERR! github.com/isaacs/npm/issues> npm ERR! System Linux 3.5.0-27-generic npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" npm ERR!cwd /home /euridice npm ERR!node -v v0.10.5 npm ERR!npm -v 1.2.18 npm ERR!path /home/euridice/package.json npm ERR!code ENOENT npm ERR!errno 34 npm ERR!not ok code 0"
  • 这就是我运行 npm install 时得到的结果。
  • 另外,git push node_modules fatal: 'node_modules' 似乎不是 git 存储库 fatal: 远端意外挂断
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-08-15
  • 2013-06-15
  • 1970-01-01
  • 1970-01-01
  • 2012-03-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多