2013-05-07 77 views
2

當我部署的應用程序,並從本教程炒高代碼: http://blog.superpat.com/2011/06/14/node-js-chat-demo-on-heroku/Heroku App根據日誌不斷崩潰...爲什麼?

我從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有什麼關係?我是否應該在某處更改數據庫路徑?

當我嘗試在本地使用節點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) 
+0

這聞起來像你沒有一個安裝在你的應用程序依賴的PG模塊。 – 2013-05-07 13:45:33

+0

作爲後續步驟,將持久性添加到聊天服務器。你是否在package.json文件中添加了一個postgres作爲依賴項?還有就是如何在原始博客文章做到這一點後來一個例子,雖然我建議使用Postgres的1.1.0版本(而不是在博客中給出的0.5版本)。謝謝 – jr0cket 2013-05-07 15:43:11

+0

@ JR0cket,不,我沒有。我想我會注意它。看我的編輯。我在哪裏可以找到將postgres添加爲依賴項的說明?我找不到它。 – 2013-05-07 18:48:20

回答

2

運行

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 

必須將)在你的node_chat文件夾,B)第一NPM安裝,然後推EVERYTHING(GIT添加)到Heroku的!

+0

「npm ERR!install無法讀取依賴關係 npm ERR!錯誤:ENOENT,open'/ home !/euridice/package.json」 NPM ERR如果您需要幫助,您可以報告此日誌中: NPM ERR NPM ERR系統的Linux 3.5! 0-27-generic npm ERR!命令「/ 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!不正常碼0" – 2013-05-07 18:19:50

+0

這就是我得到的,當我運行NPM安裝。 – 2013-05-07 18:20:15

+0

此外,git push node_modules 致命︰'node_modules'似乎不是一個混帳存儲庫 致命︰遠程端意外掛斷 – 2013-05-07 18:41:41