2017-07-26 138 views
0

我已经在我的代码中进行了大量修订,并且已经阅读了有关类似问题的各种相互冲突的博客文章。 应用程序在本地正确打开。我已经采取Node.js应用程序在部署到Heroku后未打开

附加步骤:

  • 清零和再加入的NodeJS buildpackm缩放该应用根据Heroku的文档 (Heroku的PS:规模幅= 0) (Heroku的PS:规模网络= 1),重新启动heroku应用程序。最后,我用下面的回答类似的问题:

Error while deploying Node.js App to Heroku

Heroku is giving me a 503 when trying to open my web app, works on local host

npm ERR! npm owner error triggered with H10 app crashed

在我看来,从日志显著的错误是:“Heroku的[路由器] :at =错误代码= H10 desc =“应用程序崩溃”。

任何指导将不胜感激

Heroku的日志:

macs-iMac:hooptime mac$ heroku logs 
2017-07-27T03:13:32.290426+00:00 app[web.1]: Available on: 
2017-07-27T03:13:32.291372+00:00 app[web.1]: http://localhost:8000 
2017-07-27T03:13:32.291437+00:00 app[web.1]: Hit CTRL-C to stop the server 
2017-07-27T03:14:24.468772+00:00 heroku[web.1]: State changed from starting to crashed 
2017-07-27T03:14:24.329875+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 
2017-07-27T03:14:24.329968+00:00 heroku[web.1]: Stopping process with SIGKILL 
2017-07-27T03:14:24.452131+00:00 heroku[web.1]: Process exited with status 137 
2017-07-27T03:17:53.555938+00:00 heroku[worker.1]: State changed from crashed to starting 
2017-07-27T03:17:58.615372+00:00 heroku[worker.1]: Starting process with command `node index.js` 
2017-07-27T03:17:59.234914+00:00 heroku[worker.1]: State changed from starting to up 
2017-07-27T03:18:01.127773+00:00 heroku[worker.1]: State changed from up to crashed 
2017-07-27T03:18:01.028085+00:00 app[worker.1]: module.js:471 
2017-07-27T03:18:01.028104+00:00 app[worker.1]:  throw err; 
2017-07-27T03:18:01.028105+00:00 app[worker.1]: ^
2017-07-27T03:18:01.028105+00:00 app[worker.1]: 
2017-07-27T03:18:01.028112+00:00 app[worker.1]: Error: Cannot find module '/app/index.js' 
2017-07-27T03:18:01.028121+00:00 app[worker.1]:  at Function.Module._resolveFilename (module.js:469:15) 
2017-07-27T03:18:01.028122+00:00 app[worker.1]:  at Function.Module._load (module.js:417:25) 
2017-07-27T03:18:01.028123+00:00 app[worker.1]:  at Module.runMain (module.js:604:10) 
2017-07-27T03:18:01.028123+00:00 app[worker.1]:  at run (bootstrap_node.js:389:7) 
2017-07-27T03:18:01.028124+00:00 app[worker.1]:  at startup (bootstrap_node.js:149:9) 
2017-07-27T03:18:01.028125+00:00 app[worker.1]:  at bootstrap_node.js:504:3 
2017-07-27T03:18:01.111007+00:00 heroku[worker.1]: Process exited with status 1 
2017-07-27T03:32:56.591479+00:00 heroku[worker.1]: State changed from crashed to starting 
2017-07-27T03:33:00.576960+00:00 heroku[worker.1]: Starting process with command `node index.js` 
2017-07-27T03:33:01.200876+00:00 heroku[worker.1]: State changed from starting to up 
2017-07-27T03:33:02.638384+00:00 app[worker.1]: module.js:471 
2017-07-27T03:33:02.638400+00:00 app[worker.1]:  throw err; 
2017-07-27T03:33:02.638401+00:00 app[worker.1]: ^
2017-07-27T03:33:02.638402+00:00 app[worker.1]: 
2017-07-27T03:33:02.638402+00:00 app[worker.1]: Error: Cannot find module '/app/index.js' 
2017-07-27T03:33:02.638415+00:00 app[worker.1]:  at Function.Module._resolveFilename (module.js:469:15) 
2017-07-27T03:33:02.638415+00:00 app[worker.1]:  at Function.Module._load (module.js:417:25) 
2017-07-27T03:33:02.638416+00:00 app[worker.1]:  at Module.runMain (module.js:604:10) 
2017-07-27T03:33:02.638417+00:00 app[worker.1]:  at run (bootstrap_node.js:389:7) 
2017-07-27T03:33:02.638417+00:00 app[worker.1]:  at startup (bootstrap_node.js:149:9) 
2017-07-27T03:33:02.638418+00:00 app[worker.1]:  at bootstrap_node.js:504:3 
2017-07-27T03:33:02.769228+00:00 heroku[worker.1]: Process exited with status 1 
2017-07-27T03:33:02.782955+00:00 heroku[worker.1]: State changed from up to crashed 
2017-07-27T03:36:58.088482+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=04c12935-8d88-470d-9e54-4b45e2480d67 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:00.556550+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=270fea8f-75fe-4078-8c01-c8779e5c43cb fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:12.960183+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=d31437be-fe7e-4e56-a0db-a13a8e3a28af fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:13.804392+00:00 heroku[worker.1]: State changed from crashed to starting 
2017-07-27T03:48:14.158976+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=d9cdb0e6-ab58-442f-b35b-87e72ae2cc18 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:14.505616+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/apple-touch-icon-precomposed.png" host=hooptime.herokuapp.com request_id=de46bfff-578e-4e5e-be86-c51b58b4af54 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:14.661681+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=e51259a7-0979-412d-8f93-b571e28875ef fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:14.743144+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/apple-touch-icon.png" host=hooptime.herokuapp.com request_id=fb7cd369-d821-44a1-bf30-5e378f1810fb fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:15.011171+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=82649af8-1b1c-4215-827b-41af4d827500 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:15.276467+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/apple-touch-icon-precomposed.png" host=hooptime.herokuapp.com request_id=fe831747-d46d-4ae2-9475-64bed439abb3 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:15.599565+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/apple-touch-icon.png" host=hooptime.herokuapp.com request_id=7e6fd0fa-efc7-40b6-b2da-125673765285 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:17.042432+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=4b51a77b-ae59-4583-b386-526f0a501c68 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:17.149974+00:00 heroku[worker.1]: Starting process with command `node index.js` 
2017-07-27T03:48:17.380527+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=73136e3a-46b7-4c92-9f2a-d581d3c72738 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:48:17.829826+00:00 heroku[worker.1]: State changed from starting to up 
2017-07-27T03:48:19.457599+00:00 app[worker.1]: module.js:471 
2017-07-27T03:48:19.457612+00:00 app[worker.1]:  throw err; 
2017-07-27T03:48:19.457612+00:00 app[worker.1]: ^
2017-07-27T03:48:19.457613+00:00 app[worker.1]: 
2017-07-27T03:48:19.457614+00:00 app[worker.1]: Error: Cannot find module '/app/index.js' 
2017-07-27T03:48:19.457615+00:00 app[worker.1]:  at Function.Module._load (module.js:417:25) 
2017-07-27T03:48:19.457614+00:00 app[worker.1]:  at Function.Module._resolveFilename (module.js:469:15) 
2017-07-27T03:48:19.457616+00:00 app[worker.1]:  at Module.runMain (module.js:604:10) 
2017-07-27T03:48:19.457616+00:00 app[worker.1]:  at run (bootstrap_node.js:389:7) 
2017-07-27T03:48:19.457618+00:00 app[worker.1]:  at bootstrap_node.js:504:3 
2017-07-27T03:48:19.457617+00:00 app[worker.1]:  at startup (bootstrap_node.js:149:9) 
2017-07-27T03:48:19.568292+00:00 heroku[worker.1]: Process exited with status 1 
2017-07-27T03:48:19.582653+00:00 heroku[worker.1]: State changed from up to crashed 
2017-07-27T03:53:32.129097+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=70af7304-5591-4cff-9fc7-25c309e6df5b fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:53:32.359600+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=13b24996-5231-46ce-bf16-0917f438d67c fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:54:22.676504+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=1b37ef83-7165-4f51-8028-e6e7c9223c30 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:54:22.902471+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=bab64ebe-b273-4b57-94e9-c795833e0f68 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:56:00.492646+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=4bb60171-35b7-4fe0-afd9-f4c43d4357b9 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:56:00.721576+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=2dee01f7-5392-40b5-b9d2-38178f32e698 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:56:02.052904+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=15afa6fc-8216-48f9-a637-92c82506b4ce fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:56:02.265575+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=998e5185-b367-4121-9bdc-5673d37deeff fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:57:27.796870+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=e753734d-79ed-4c36-8e6f-08e591edafee fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:57:28.036446+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=e0147f98-9f83-4c51-a6c8-cb3d9c46c47b fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:58:30.003002+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=00c1688f-740f-4cbf-9d0d-cc6c25d23cf4 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:58:30.226148+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=c7c59508-0d33-4e98-b2a3-4c8ebfd8529f fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:58:30.878029+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=ec7d5038-82eb-4c12-aed6-0488401f7a9e fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T03:58:31.085787+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=15f39eec-de96-48f0-8f6b-575cd688ba91 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T04:02:16.853379+00:00 heroku[worker.1]: State changed from crashed to starting 
2017-07-27T04:02:21.100226+00:00 heroku[worker.1]: Starting process with command `node index.js` 
2017-07-27T04:02:21.727262+00:00 heroku[worker.1]: State changed from starting to up 
2017-07-27T04:02:23.099454+00:00 app[worker.1]: module.js:471 
2017-07-27T04:02:23.099481+00:00 app[worker.1]:  throw err; 
2017-07-27T04:02:23.099482+00:00 app[worker.1]: ^
2017-07-27T04:02:23.099482+00:00 app[worker.1]: 
2017-07-27T04:02:23.099484+00:00 app[worker.1]:  at Function.Module._resolveFilename (module.js:469:15) 
2017-07-27T04:02:23.099483+00:00 app[worker.1]: Error: Cannot find module '/app/index.js' 
2017-07-27T04:02:23.099485+00:00 app[worker.1]:  at Function.Module._load (module.js:417:25) 
2017-07-27T04:02:23.099485+00:00 app[worker.1]:  at Module.runMain (module.js:604:10) 
2017-07-27T04:02:23.099486+00:00 app[worker.1]:  at run (bootstrap_node.js:389:7) 
2017-07-27T04:02:23.099486+00:00 app[worker.1]:  at startup (bootstrap_node.js:149:9) 
2017-07-27T04:02:23.099487+00:00 app[worker.1]:  at bootstrap_node.js:504:3 
2017-07-27T04:02:23.189149+00:00 heroku[worker.1]: Process exited with status 1 
2017-07-27T04:02:23.199937+00:00 heroku[worker.1]: State changed from up to crashed 
2017-07-27T04:03:40.500129+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=e1058a8e-46a1-4372-a702-f616540f792a fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T04:03:40.730673+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=3ffc8109-d893-43fc-8478-132ef1744a3d fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T04:03:41.990804+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=hooptime.herokuapp.com request_id=fd31d62c-c0f9-4acc-b72c-3d80d1d0d362 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
2017-07-27T04:03:42.209388+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=hooptime.herokuapp.com request_id=5b07975b-ffe1-43e6-8d72-7acf905d4bf2 fwd="66.205.150.33" dyno= connect= service= status=503 bytes= protocol=https 
macs-iMac:hooptime mac$ 

Procfile:

worker: node index.js 

的package.json:

 { 
    "name": "hooptime", 
    "description": "Our sample Node to Heroku app", 
    "engines": { "node": "7.1.0"}, 
    "main": "server.js", 
    "scripts": { 
    "start": "node server.js" 
    }, 
    "dependencies": { 
    "express": "~4.9.8" 
    } 
} 

index.js:

 var express = require('express'); 
var bodyParser = require('body-parser'); 

var app = express(); 

app.set('port', (process.env.PORT || 8080)); 
app.use(express.static(__dirname + '/app')); 
app.set('views', __dirname + '/app/parks/'); 
app.engine('html', require('ejs').renderFile); 
app.set('view engine', 'html'); 

app.use(bodyParser.urlencoded({ 
    extended: true 
})); 
app.use(bodyParser.json()); 

app.get('*', function(req, res){ 
    res.render('register.view.html'); 
}); 

app.listen(app.get('port'), function() { 
}); 

structure of app

回答

1

在你Procfile你定义为工人

worker: node index.js 

但是你的主文件名为server.js所以你应该定义为Procfile

worker: node server.js 
+0

嗨@arpit 谢谢您的答复。我继续前进,然后进行了更改,但是我的日志中还提到另一个错误:错误:找不到模块'/app/index.js' 我正在从根项目路径运行应用程序,我可以确认有一个index.js文件。我用位于index.js中的代码更新了我的问题。任何其他想法? –

+0

如果您的Procfile和server.js不在同一个目录中,那么您必须将相对路径放在worker中,我建议将该文件重命名为index.js –

+0

再次感谢您的建议。我接受了你的建议,并且: 1.更名服务器。 js - > index.js 2.更新/移动Procfile和新改名的index.js到项目目录的根目录 3.压缩我的package.json 我已经添加了我的新日志和文件到问题中,并添加了我的项目结构的屏幕截图。无论我将index.js移入还是移出app目录,我都会继续看到“无法找到模块:/app/index.js”的错误。我已经通过heroku重新启动了应用程序,重新调整了工作人员,并将代码重新推送到了heroku。想到其他任何解决方案? –