当我尝试在heroku上启动我的应用程序时,我收到以下错误,但它在终端上的节点运行良好,例如。 node server.js
。
有没有人遇到过这个问题?
我使用以下依赖项:
"dependencies": {
"express": "~3.4.8",
"mongodb": "1.1.8",
"socket.io": "0.9.10",
"backbone": "~1.1.1",
"bootstrap": "0.0.2",
"node.js": "0.0.0"
},
"engines": {
"node": "0.8.4",
"npm": "1.1.49"
}
我收到以下错误:应用程序中发生错误,无法提供您的页面。请稍后再试。
这是我的heroku日志中的错误。
e3-a69c-3a07d518e05a fwd="50.157.213.109" dyno=web.1 connect=0ms service=3ms status=304
bytes=238
2014-02-17T14:35:35.140966+00:00 app[web.1]:
2014-02-17T14:35:35.141400+00:00 app[web.1]: http.js:691
2014-02-17T14:35:35.141652+00:00 app[web.1]: throw new Error('Can\'t set headers after they are sent.');
2014-02-17T14:35:35.141652+00:00 app[web.1]: ^
2014-02-17T14:35:35.144602+00:00 app[web.1]: Error: Can't set headers after they are sent.
2014-02-17T14:35:35.140544+00:00 app[web.1]: GET / 304 2ms
2014-02-17T14:35:35.144602+00:00 app[web.1]: at SendStream.send (/app/node_modules/express/node_modules/send/lib/send.js:348:8)
2014-02-17T14:35:35.144602+00:00 app[web.1]: at /app/node_modules/express/node_modules/send/lib/send.js:323:10
2014-02-17T14:35:35.144602+00:00 app[web.1]: at Object.oncomplete (fs.js:107:15)
2014-02-17T14:35:35.140544+00:00 app[web.1]: GET / 304 2ms
2014-02-17T14:35:35.144602+00:00 app[web.1]: at ServerResponse.OutgoingMessage.setHeader (http.js:691:11)
2014-02-17T14:35:35.144602+00:00 app[web.1]: at ServerResponse.res.setHeader (/app/node_modules/express/node_modules/connect/lib/patch.js:63:22)
2014-02-17T14:35:35.144602+00:00 app[web.1]: at SendStream.type (/app/node_modules/express/node_modules/send/lib/send.js:456:7)
2014-02-17T14:35:36.268983+00:00 heroku[web.1]: Process exited with status 8
2014-02-17T14:35:36.284405+00:00 heroku[web.1]: State changed from up to crashed
2014-02-17T14:35:36.286612+00:00 heroku[web.1]: State changed from crashed to starting
2014-02-17T14:35:38.836042+00:00 heroku[web.1]: Starting process with command `node serverwithanalytics.js`
2014-02-17T14:35:40.503178+00:00 app[web.1]: connect.multipart() will be removed in connect 3.0
2014-02-17T14:35:40.503366+00:00 app[web.1]: visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
2014-02-17T14:35:40.504851+00:00 app[web.1]: connect.limit() will be removed in connect 3.0
2014-02-17T14:35:40.508557+00:00 app[web.1]: info: socket.io started
2014-02-17T14:35:40.514996+00:00 app[web.1]: Express server listening on port 44412
2014-02-17T14:35:43.280881+00:00 heroku[router]: at=info method=GET path=/css/bootstrap-responsive.css host=peaceful-waters-4142.herokuapp.com request_id=3a5ed1cc-1065-4e74-ba1d-91cb0b799e6c fwd="50.157.213.109" dyno=web.1 connect=1ms service=68ms status=304 bytes=239
2014-02-17T14:35:43.275568+00:00 app[web.1]: GET /css/bootstrap-responsive.css 304 42ms
2014-02-17T14:35:43.287066+00:00 app[web.1]:
2014-02-17T14:35:43.288991+00:00 app[web.1]: http.js:691
2014-02-17T14:35:43.286558+00:00 app[web.1]: GET /css/bootstrap-responsive.css 304 53ms
2014-02-17T14:35:43.295520+00:00 app[web.1]: at SendStream.type (/app/node_modules/express/node_modules/send/lib/send.js:456:7)
2014-02-17T14:35:43.291840+00:00 app[web.1]: throw new Error('Can\'t set headers after they are sent.');
2014-02-17T14:35:43.291840+00:00 app[web.1]: ^
2014-02-17T14:35:43.295520+00:00 app[web.1]: at ServerResponse.OutgoingMessage.setHeader (http.js:691:11)
2014-02-17T14:35:43.295520+00:00 app[web.1]: Error: Can't set headers after they are sent.
2014-02-17T14:35:43.295520+00:00 app[web.1]: at ServerResponse.res.setHeader (/app/node_modules/express/node_modules/connect/lib/patch.js:63:22)
2014-02-17T14:35:43.295520+00:00 app[web.1]: at SendStream.send (/app/node_modules/express/node_modules/send/lib/send.js:348:8)
2014-02-17T14:35:43.295520+00:00 app[web.1]: at /app/node_modules/express/node_modules/send/lib/send.js:323:10
2014-02-17T14:35:43.295520+00:00 app[web.1]: at Object.oncomplete (fs.js:107:15)
2014-02-17T14:35:45.002412+00:00 heroku[web.1]: State changed from up to crashed
2014-02-17T14:35:44.989848+00:00 heroku[web.1]: Process exited with status 8
答案 0 :(得分:1)
您在发送标题后无法设置标题。
这是某种代码逻辑错误,例如,在应用页面向客户端发送响应后,可能会有代码行或循环继续。
请参阅http.js的第691行或显示您的代码以获取更具体的帮助。