2014-07-19 100 views
6

我有一個Node.js,它在本地運行良好,但在我嘗試在Heroku上運行時崩潰。在Heroku上使用快速應用程序崩潰的Node.js,在本地工作

當我部署和去Heroku的子域:

  • 的HTML負載,但在CSS不
  • 當我刷新沒什麼載荷和我得到的通用應用程序錯誤
  • 綜觀日誌似乎應用程序已經崩潰

任何想法爲什麼heroku不斷崩潰?最好的猜測是我的靜態文件。

下面是日誌:

2014-07-19T02:02:00.723361+00:00 heroku[router]: at=error code=H13 desc="Connection closed  without response" method=GET path="/javascripts/main.js" host=sendmyemail.herokuapp.com  request_id=3f2d4cd8-c70d-4506-9baf-af8d98983f37 fwd="99.43.254.71" dyno=web.1 connect=1 service=43 status=503 bytes=691 
2014-07-19T02:02:00.708143+00:00 app[web.1]:   throw er; // Unhandled 'error' event 
2014-07-19T02:02:00.709158+00:00 app[web.1]:  at errnoException (child_process.js:988:11) 
2014-07-19T02:02:00.708150+00:00 app[web.1]:    ^
2014-07-19T02:02:00.707641+00:00 app[web.1]: 
2014-07-19T02:02:00.707753+00:00 app[web.1]: events.js:72 
2014-07-19T02:02:00.709155+00:00 app[web.1]: Error: spawn ENOENT 
2014-07-19T02:02:00.709160+00:00 app[web.1]:  at Process.ChildProcess._handle.onexit (child_process.js:779:34) 
2014-07-19T02:02:02.265464+00:00 heroku[web.1]: State changed from up to crashed 
2014-07-19T02:02:03.554266+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sendmyemail.herokuapp.com request_id=fc319b3f-924f-4e37-bf6f-a58a4dc25770 fwd="99.43.254.71" dyno=web.1 connect=100 service= status=503 bytes= 
2014-07-19T02:02:02.255985+00:00 heroku[web.1]: Process exited with status 8 

這裏是我的package.json:

{ 
    "name": "myapp", 
    "version": "0.0.1", 
    "engines": { 
    "node": "0.10.26", 
    "npm": "1.4.20" 
    }, 
    "scripts": { 
    "start": "node app.js" 
    }, 
    "dependencies": { 
    "express": "~4.2.0", 
    "body-parser": "^1.4.3", 
    "node-compass": "0.2.3", 
    "ejs": "~1.0.0", 
    "express-ejs-layouts": "~1.1.0", 
    "mailgun-js": "^0.5.1" 
    } 
} 

我有我的公共文件夾中的CSS和JS和這一行中app.js:

app.use(express['static'](path.join(__dirname, 'public'))); 
+0

你能發佈你的版本庫結構嗎? – paradite

回答

10

我將引用靜態文件(express.static)的代碼行移至其他代碼行上,現在它可以正常工作奧。

app.use(express.static(__dirname + '/public')); 
app.engine('html', require('ejs').renderFile); 
app.set('view engine', 'html'); 
app.set('layout', 'layout'); // defaults to 'layout' 
app.use(require('node-compass')({mode: 'expanded'})); 
app.use(expressLayouts); 
app.use(bodyParser.urlencoded({ extended: false })); 
+3

它爲我工作,但是,爲什麼它有效? – Capy

+0

也適用於我。奇怪的。 – sent1nel

相關問題