I'm building an app and I've gotten to the point where deployment to HEROKU was successful. On opening app(/), I get APPLICATION ERROR, I checked log with CLI mand and this is what I get:
2018-10-22T09:06:32.000000+00:00 app[api]: Build started by user [email protected]
2018-10-22T09:06:45.572183+00:00 app[api]: Deploy 7bc663ae by user [email protected]
2018-10-22T09:06:45.572183+00:00 app[api]: Release v24 created by user [email protected]
2018-10-22T09:06:45.826688+00:00 heroku[web.1]: State changed from crashed to starting
2018-10-22T09:06:47.000000+00:00 app[api]: Build succeeded
2018-10-22T09:06:49.116924+00:00 heroku[web.1]: Starting process with mand `npm start`
2018-10-22T09:06:53.099327+00:00 app[web.1]:
2018-10-22T09:06:53.099345+00:00 app[web.1]: > [email protected] start /app
2018-10-22T09:06:53.099347+00:00 app[web.1]: > node index.js
2018-10-22T09:06:53.099349+00:00 app[web.1]:
2018-10-22T09:06:53.840102+00:00 heroku[web.1]: Process exited with status 0
2018-10-22T09:06:53.856482+00:00 heroku[web.1]: State changed from starting to crashed
2018-10-22T09:06:53.858384+00:00 heroku[web.1]: State changed from crashed to starting
2018-10-22T09:06:57.152906+00:00 heroku[web.1]: Starting process with mand `npm start`
2018-10-22T09:07:00.298331+00:00 app[web.1]:
2018-10-22T09:07:00.298348+00:00 app[web.1]: > [email protected] start /app
2018-10-22T09:07:00.298350+00:00 app[web.1]: > node index.js
2018-10-22T09:07:00.298351+00:00 app[web.1]:
2018-10-22T09:07:00.979144+00:00 heroku[web.1]: Process exited with status 0
2018-10-22T09:07:00.997278+00:00 heroku[web.1]: State changed from starting to crashed
2018-10-22T09:07:20.183091+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=odm-mobile.herokuapp request_id=c9a8b164-2f61-459b-87da-56518ce4dc81 fwd="154.120.97.254" dyno= connect= service= status=503 bytes= protocol=https
2018-10-22T09:07:22.293716+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=odm-mobile.herokuapp request_id=6870b281-7607-4882-8bac-e97c38169e26 fwd="154.120.97.254" dyno= connect= service= status=503 bytes= protocol=https
2018-10-22T09:25:14.164205+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=odm-mobile.herokuapp request_id=af0d9ab3-8a64-494e-8b2e-4b5e0a46f7fd fwd="154.120.97.254" dyno= connect= service= status=503 bytes= protocol=https
2018-10-22T09:25:15.783603+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=odm-mobile.herokuapp request_id=dcd6cc6f-0959-4ca7-b4d4-43143e952b8c fwd="154.120.97.254" dyno= connect= service= status=503 bytes= protocol=https`
The following are the files that I'm working with on dreamweaver
index.js
var port = Number(process.env.PORT|| 5000); var express = require('express'), moment = require('moment'); var exports = module.exports = function(dir, options) { var modules = {}; options = merge(options || {}, { lazy: true }); fs.readdirSync(dir).forEach(function(filename) { // filter index and dotfiles if (filename !== 'index.js' && filename[0] !== '.') { var moduleName = path.basename(filename, path.extname(filename)); var modulePath = path.join(dir, moduleName); // lazy load if (options.lazy) { Object.defineProperty(modules, moduleName, { get: function() { return require(modulePath); } }); } else { modules[moduleName] = require(modulePath); } } }); return modules; };
I'm building an app and I've gotten to the point where deployment to HEROKU was successful. On opening app(https://odm-mobile.herokuapp./), I get APPLICATION ERROR, I checked log with CLI mand and this is what I get:
2018-10-22T09:06:32.000000+00:00 app[api]: Build started by user [email protected] 2018-10-22T09:06:45.572183+00:00 app[api]: Deploy 7bc663ae by user [email protected] 2018-10-22T09:06:45.572183+00:00 app[api]: Release v24 created by user [email protected] 2018-10-22T09:06:45.826688+00:00 heroku[web.1]: State changed from crashed to starting 2018-10-22T09:06:47.000000+00:00 app[api]: Build succeeded 2018-10-22T09:06:49.116924+00:00 heroku[web.1]: Starting process with mand `npm start` 2018-10-22T09:06:53.099327+00:00 app[web.1]: 2018-10-22T09:06:53.099345+00:00 app[web.1]: > [email protected] start /app 2018-10-22T09:06:53.099347+00:00 app[web.1]: > node index.js 2018-10-22T09:06:53.099349+00:00 app[web.1]: 2018-10-22T09:06:53.840102+00:00 heroku[web.1]: Process exited with status 0 2018-10-22T09:06:53.856482+00:00 heroku[web.1]: State changed from starting to crashed 2018-10-22T09:06:53.858384+00:00 heroku[web.1]: State changed from crashed to starting 2018-10-22T09:06:57.152906+00:00 heroku[web.1]: Starting process with mand `npm start` 2018-10-22T09:07:00.298331+00:00 app[web.1]: 2018-10-22T09:07:00.298348+00:00 app[web.1]: > [email protected] start /app 2018-10-22T09:07:00.298350+00:00 app[web.1]: > node index.js 2018-10-22T09:07:00.298351+00:00 app[web.1]: 2018-10-22T09:07:00.979144+00:00 heroku[web.1]: Process exited with status 0 2018-10-22T09:07:00.997278+00:00 heroku[web.1]: State changed from starting to crashed 2018-10-22T09:07:20.183091+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=odm-mobile.herokuapp. request_id=c9a8b164-2f61-459b-87da-56518ce4dc81 fwd="154.120.97.254" dyno= connect= service= status=503 bytes= protocol=https 2018-10-22T09:07:22.293716+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=odm-mobile.herokuapp. request_id=6870b281-7607-4882-8bac-e97c38169e26 fwd="154.120.97.254" dyno= connect= service= status=503 bytes= protocol=https 2018-10-22T09:25:14.164205+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=odm-mobile.herokuapp. request_id=af0d9ab3-8a64-494e-8b2e-4b5e0a46f7fd fwd="154.120.97.254" dyno= connect= service= status=503 bytes= protocol=https 2018-10-22T09:25:15.783603+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=odm-mobile.herokuapp. request_id=dcd6cc6f-0959-4ca7-b4d4-43143e952b8c fwd="154.120.97.254" dyno= connect= service= status=503 bytes= protocol=https`
The following are the files that I'm working with on dreamweaver
index.js
var port = Number(process.env.PORT|| 5000); var express = require('express'), moment = require('moment'); var exports = module.exports = function(dir, options) { var modules = {}; options = merge(options || {}, { lazy: true }); fs.readdirSync(dir).forEach(function(filename) { // filter index and dotfiles if (filename !== 'index.js' && filename[0] !== '.') { var moduleName = path.basename(filename, path.extname(filename)); var modulePath = path.join(dir, moduleName); // lazy load if (options.lazy) { Object.defineProperty(modules, moduleName, { get: function() { return require(modulePath); } }); } else { modules[moduleName] = require(modulePath); } } }); return modules; };
package.json
{ "name": "odm-mobile", "version": "1.0.0", "description": "odm daily devotional", "main": "index.js", "scripts": { "start": "node index.js" }, "keywords": [], "author": "xdoshent <[email protected]>", "license": "MIT", "repository": { "type": "git", "url": "odm-mobile" }, "dependencies": { "@fortawesome/fontawesome-free": "^5.4.1", "express": "^4.16.4", "index.js": "0.0.3", "moment": "^2.22.2", "packages": "0.0.8" }, "engines": { "node": "8.12.0", "engines": { "npm": "6.4.1" } } }
Procfile
web: node index.js
Pls clearly point out the issues I might be having and errors in the files I'm working with as I'm new to all these
Share Improve this question asked Oct 22, 2018 at 11:11 X-Dosh EntertainmentX-Dosh Entertainment 311 gold badge1 silver badge2 bronze badges 02 Answers
Reset to default 3Heroku isn't a FaaS service, it's a PaaS. I see that you've exported a function, but it ends there. Ensure that you're running a long-running application i.e. daemon. As stated clearly in logs, your application doesn't wait for anything and directly exits with return code
0
which indicates that the program has finished execution successfully. I'm not a Node.js developer but having a look at the Hello World example by ExpressJS will most likely help you understand why things didn't work this time.https://expressjs./en/starter/hello-world.html
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
This line does the work in the code snippet by ExpressJS. It starts listening to ining connections, so it blocks forever until killed and accepts connections.
Case 1: Procfile
in Procfile there should be no spaces betweenweb:
andnode index.js
.- incorrect:
web: node index.js
- correct:
web:node index.js
Case 2: devDependency
There should not be any dev dependencies on the server, as heroku didn't install devDependencies by default. So either changedevDependencies
todependencies
in your package.json, or run:heroku config:set NPM_CONFIG_PRODUCTION=false