Node app on Heroku - getting "Application Error" - all my dependencies are in the json package

Node app on Heroku - getting "Application Error" - all my dependencies are in the json package
0

#1

Greeting, campers!

I have looked through the similar topics and have so far been unable to resolve my deployment issue.

When I tun the image search data abstraction layer app from Heroku, I get th “Application error” message.

Any ideas?

https://imgsrchabstrxlyer.herokuapp.com/

thanks!


#2

Can you show us the heroku logs?


#3

-----> Node.js app detected
-----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error
   NPM_CONFIG_PRODUCTION=true
   NODE_VERBOSE=false
   NODE_ENV=production
   NODE_MODULES_CACHE=true

-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)

   Resolving node version 6.x...
   Downloading and installing node 6.11.4...
   Using default npm version: 3.10.10

-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules
- bower_components (not cached - skipping)
-----> Building dependencies
Installing node modules (package.json)
-----> Caching build
Clearing previous node cache
Saving 2 cacheDirectories (default):
- node_modules
- bower_components (nothing to cache)
-----> Build succeeded!
-----> Discovering process types
Procfile declares types -> (none)
Default types for buildpack -> web
-----> Compressing…
Done: 22.8M
-----> Launching…
Released v12
https://imgsrchabstrxlyer.herokuapp.com/ deployed to Heroku


#4

Run heroku logs to see an error that occurs.
Also check that you don’t use static port number. Heroku sets port number through process.env.PORT


#5

Do you get any error logs when you run this at the command line:

heroku logs -t

Also, unrelated, but you need to hide your database username and password (and Google API keys) in a .env file and use the dotenv npm package if you are going to use a public git repo - anyone can currently access your database…


#6

Oh my yeah I have to do that


#7

2017-10-15T19:57:06.332613+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" host=imgsrchabstrxlyer.herokuapp.com request_id=49504d6c-532a-4dd0-86c6-4b0b9686c2e2 fwd=“71.62.55.64” dyno= connect= service= status=503 bytes= protocol=https
2017-10-15T19:57:06.702690+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=imgsrchabstrxlyer.herokuapp.com request_id=305c823e-e07f-40fe-8a2c-718318b1da0e fwd=“71.62.55.64” dyno= connect= service= status=503 bytes= protocol=https


#8
app.get('/', (req, res, next) => res.sendFile(path.join(__dirname, '/node_modules/index.html')) ) ;```
Why your index.html in node_modules?

#9

I just fixed that locally, tested locally, updated Github, re-deployed to Heroku, and rerean the app.’

Still getting Application Error

2017-10-15T20:25:05.997623+00:00 app[web.1]: npm ERR! node app.js
2017-10-15T20:25:05.997702+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-10-15T20:25:05.997785+00:00 app[web.1]: npm ERR! npm bugs urlshortener
2017-10-15T20:25:05.997904+00:00 app[web.1]: npm ERR! Or if that isn’t available, you can get their info via:
2017-10-15T20:25:05.997985+00:00 app[web.1]: npm ERR! npm owner ls urlshortener
2017-10-15T20:25:05.998071+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-10-15T20:25:06.001186+00:00 app[web.1]:
2017-10-15T20:25:06.001415+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-10-15T20:25:06.001482+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-10-15T20:25:06.067697+00:00 heroku[web.1]: Process exited with status 1
2017-10-15T20:25:06.084718+00:00 heroku[web.1]: State changed from starting to crashed


#10

Hmmmm

I get “command not found”


#11

Weird - not sure why.

It’s just another version of the log command you’ve already run up above (it streams the output rather than giving you the last dump…you can run it in the background while you test things to see logs as they are generated)


#12

Try index.html without the slash:

app.get('/', (req, res, next) => res.sendFile(path.join(__dirname, 'index.html')) ) ;

I don’t think you need it and it might be throwing an extra one in there…not sure


#13

OK, I just tried that, re-deployed the changes from Github to Heroku, then re-ran the app

Still got ‘Application Error’

earlier I did do a system restart so it is not a caching issue

2017-10-15T21:00:22.381654+00:00 heroku[web.1]: State changed from starting to crashed
2017-10-15T21:00:22.365627+00:00 heroku[web.1]: Process exited with status 1
2017-10-15T21:00:25.820046+00:00 heroku[run.1688]: State changed from up to complete
2017-10-15T21:00:25.805032+00:00 heroku[run.1688]: Process exited with status 127
2017-10-15T21:00:36.048398+00:00 app[api]: Starting process with command bash by user [email protected]
2017-10-15T21:00:38.517883+00:00 heroku[run.7225]: Awaiting client
2017-10-15T21:00:38.550106+00:00 heroku[run.7225]: Starting process with command bash
2017-10-15T21:00:38.735404+00:00 heroku[run.7225]: State changed from starting to up
2017-10-15T21:00:58.834057+00:00 heroku[run.7225]: Client connection closed. Sending SIGHUP to all processes
2017-10-15T21:00:59.369922+00:00 heroku[run.7225]: State changed from up to complete
2017-10-15T21:00:59.356172+00:00 heroku[run.7225]: Process exited with status 127
2017-10-15T21:01:07.539284+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=imgsrchabstrxlyer.herokuapp.com request_id=afc4dfab-10e5-47ff-953f-bae89dc5c412 fwd=“71.62.55.64” dyno= connect= service= status=503 bytes= protocol=https
2017-10-15T21:01:07.409520+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" host=imgsrchabstrxlyer.herokuapp.com request_id=94130cd1-37e6-4654-8e30-bc42f38f5da0 fwd=“71.62.55.64” dyno= connect= service= status=503 bytes= protocol=https


#14

You’re getting the GET / error again, so maybe the path.join thing I suggested was wrong (assuming you didn’t get that part of the error log prior to that change?)


#15

I changed “index” back to “/index”. Also noticed in the scripts statement on the json package I have “node app.js” Changed that to “node app” ---- still getting error message when trying to view the app from Heroku

2017-10-15T21:09:09.454452+00:00 app[web.1]: npm ERR! npm bugs urlshortener
2017-10-15T21:09:09.454605+00:00 app[web.1]: npm ERR! Or if that isn’t available, you can get their info via:
2017-10-15T21:09:09.454702+00:00 app[web.1]: npm ERR! npm owner ls urlshortener
2017-10-15T21:09:09.454813+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-10-15T21:09:09.459069+00:00 app[web.1]:
2017-10-15T21:09:09.459285+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-10-15T21:09:09.459373+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2017-10-15T21:09:09.564157+00:00 heroku[web.1]: State changed from starting to crashed
2017-10-15T21:09:09.550130+00:00 heroku[web.1]: Process exited with status 1
2017-10-15T21:09:10.183404+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" host=imgsrchabstrxlyer.herokuapp.com request_id=73a3b03e-7892-4a9d-a736-9c13201f60d5 fwd=“71.62.55.64” dyno= connect= service= status=503 bytes= protocol=https
2017-10-15T21:09:10.347527+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=imgsrchabstrxlyer.herokuapp.com request_id=edd5bb57-b780-4004-89b8-34d2d04e7090 fwd=“71.62.55.64” dyno= connect= service= status=503 bytes= protocol=https

I am burning up google trying to figure this one out!


#16

const searches = require('./models/searches');
There is no such file in your repo so require throws an error


#17

THAT"S IT!!!

Remnant code strikes again.

I just commented that line out and now it is working!

Thank you!!!