简单的NodeJS部署到Heroku

我试图部署一个痛苦简单的NodeJS应用程序到Heroku。

var http = require('http'); var server = http.createServer(function(req, res) { res.writeHead(200); res.end('Hello World'); }).listen(3000); 

我已经在本地进行了testing,并运行以下命令。

 heroku login heroku create marktyers git push heroku master heroku ps:scale web=1 

该应用程序似乎部署,但是当我查看的URL我得到一个应用程序错误。

 https://marktyers.herokuapp.com 

这里是英雄日志。

节点server.js

 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=marktyers.heroku app.com request_id=d2ccf200-f034-4b62-951a-0a1d3055bf35 fwd="90.244.82.220" dyno= connect= service= status=503 bytes= heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch heroku[web.1]: Stopping process with SIGKILL heroku[web.1]: State changed from starting to crashed heroku[web.1]: Process exited with status 137 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=marktyers.herokuapp.com request_id=d63e046a-ec03-488b-930d-2ac05d006e56 fwd="90.244.82.220" dyno= connect= service= status=503 bytes= heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=marktyers.herokuapp.com request_id=21ba5a8b-2074-4798-8b40-ff0ea140bb1e fwd="90.244.82.220" dyno= connect= service= status=503 bytes= 

Heroku提供的示例应用程序使用Express包,因此没有什么用处,可以帮助我理解问题。

这是推送时的消息:

 remote: node_modules cached: false remote: remote: NPM_CONFIG_PRODUCTION=true remote: NODE_MODULES_CACHE=true remote: remote: -----> Installing binaries remote: Resolving node version (latest stable) via semver.io... remote: Downloading and installing node 0.12.2... remote: Using default npm version: 2.7.4 remote: remote: -----> Building dependencies remote: No cache available remote: Installing node modules remote: npm WARN package.json Heroku@1.0.0 No README data remote: remote: -----> Checking startup method remote: No Procfile; Adding 'web: npm start' to new Procfile remote: remote: -----> Finalizing build remote: Creating runtime environment remote: Exporting binary paths remote: Cleaning npm artifacts remote: Cleaning previous cache remote: Caching results for future builds remote: remote: -----> Build succeeded! remote: remote: Heroku@1.0.0 /tmp/build_a046b18bb77857c1547f983f14ba04b9 remote: └── (empty) remote: remote: WARNING: Node version not specified in package.json remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version remote: remote: -----> Discovering process types remote: Procfile declares types -> web remote: remote: -----> Compressing... done, 9.1MB remote: -----> Launching... done, v3 remote: https://marktyers.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/marktyers.git * [new branch] master -> master 

       

网上收集的解决方案 "简单的NodeJS部署到Heroku"