0

我是 heroku 的新手,第一次运行我的 node.js 应用程序时出现应用程序错误。由于程序在本地运行良好,因此我无法辨别到底是什么问题。这是日志。如果需要,我可以发布 node.js 代码,但具体来说我知道

http.listen(process.env.PORT || 3000, function(){
console.log('listening on *:3000');
});

应该是对的

2016-06-06T23:38:54.950995+00:00 heroku[api]: Release v2 created by 96benchu@gmail.com
2016-06-06T23:38:54.950923+00:00 heroku[api]: Enable Logplex by 96benchu@gmail.com
2016-06-06T23:39:20.282705+00:00 heroku[api]: Scale to web=1 by 96benchu@gmail.com
2016-06-06T23:39:20.283517+00:00 heroku[api]: Deploy 5244c81 by 96benchu@gmail.com
2016-06-06T23:39:20.283586+00:00 heroku[api]: Release v3 created by 96benchu@gmail.com
2016-06-06T23:39:20.707206+00:00 heroku[slug-compiler]: Slug compilation started
2016-06-06T23:39:20.707211+00:00 heroku[slug-compiler]: Slug compilation finished
2016-06-06T23:39:22.230869+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-06T23:39:24.373251+00:00 app[web.1]: npm ERR! Linux 3.13.0-85-generic
2016-06-06T23:39:24.373791+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-06-06T23:39:24.374028+00:00 app[web.1]: npm ERR! node v5.11.1
2016-06-06T23:39:24.374471+00:00 app[web.1]: npm ERR! npm  v3.8.6
2016-06-06T23:39:24.375629+00:00 app[web.1]:
2016-06-06T23:39:24.376442+00:00 app[web.1]: npm ERR! missing script: start
2016-06-06T23:39:24.376571+00:00 app[web.1]: npm ERR!
2016-06-06T23:39:24.376669+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2016-06-06T23:39:24.376763+00:00 app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
2016-06-06T23:39:24.384251+00:00 app[web.1]:
2016-06-06T23:39:24.384417+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-06-06T23:39:24.384520+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-06-06T23:39:25.117419+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-06T23:39:25.118722+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-06T23:39:25.105763+00:00 heroku[web.1]: Process exited with status 1
2016-06-06T23:39:26.845316+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-06T23:39:30.360228+00:00 app[web.1]: npm ERR! Linux 3.13.0-85-generic
2016-06-06T23:39:30.360970+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-06-06T23:39:30.361314+00:00 app[web.1]: npm ERR! node v5.11.1
2016-06-06T23:39:30.362144+00:00 app[web.1]: npm ERR! npm  v3.8.6
2016-06-06T23:39:30.364140+00:00 app[web.1]:
2016-06-06T23:39:30.365320+00:00 app[web.1]: npm ERR! missing script: start
2016-06-06T23:39:30.365478+00:00 app[web.1]: npm ERR!
2016-06-06T23:39:30.365600+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2016-06-06T23:39:30.365735+00:00 app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
2016-06-06T23:39:30.381812+00:00 app[web.1]:
2016-06-06T23:39:30.382074+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-06-06T23:39:30.382233+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-06-06T23:39:31.427206+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-06T23:39:31.409170+00:00 heroku[web.1]: Process exited with status 1
2016-06-06T23:40:10.611044+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secret-eyrie-35026.herokuapp.com request_id=9e530180-b522-4412-a321-54b90430b82f fwd="172.6.205.107" dyno= connect= service= status=503 bytes=
2016-06-06T23:40:11.404313+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secret-eyrie-35026.herokuapp.com request_id=f039df37-b206-41df-80b8-5076330ae67f fwd="172.6.205.107" dyno= connect= service= status=503 bytes=
2016-06-06T23:41:02.960874+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=secret-eyrie-35026.herokuapp.com request_id=0ad763f1-7a6f-4324-b9ad-f81891d4ccba fwd="172.6.205.107" dyno= connect= service= status=503 bytes=
2016-06-06T23:41:03.729436+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secret-eyrie-35026.herokuapp.com request_id=790a0e38-360c-447d-80a6-fa57914faf15 fwd="172.6.205.107" dyno= connect= service= status=503 bytes=
4

1 回答 1

3

您可以在 package.json 中添加启动脚本,如下所示:

"scripts": {
    "start": "node index.js"
},

这样您的 package.json 将如下所示:

{ 
    "name": "socket-chat-example", 
    "version": "0.0.1", 
    "description": "my first socket.io app", 
    "scripts": {
        "start": "node index.js"
    },
    "dependencies": { "express": "~4.10.2", "socket.io": "1.2.0", } 
} 
于 2016-10-18T00:52:17.627 回答