generator-webapp icon indicating copy to clipboard operation
generator-webapp copied to clipboard

Deploying to Heroku using Node.js not working?

Open NuroDev opened this issue 7 years ago • 6 comments

Been attempting to get a web app running on Heroku using NodeJS. Used the provided recipe for setting it up: node-heroku . However, the app builds correctly on Heroku, but when visiting the app page, it returns an application error. Tested it with the configuration that I used and base configuration of all config options enabled(BDD & TDD). Still same issue. Is it an issue with Heroku or the generator?

NuroDev avatar Feb 11 '17 18:02 NuroDev

If more information is required, link to repository can be found here: github.com/Meadowcottage/KaplanSays. The dist files was made in the order provided by the deploying to heroku using node.js recipe.

I have checked the Heroku logs and the crash log returns the following:

2017-02-21T22:12:25.394968+00:00 heroku[web.1]: Starting process with command `npm start`
2017-02-21T22:12:28.366684+00:00 heroku[web.1]: Process exited with status 1
2017-02-21T22:12:28.384951+00:00 heroku[web.1]: State changed from starting to crashed
2017-02-21T22:12:28.282442+00:00 app[web.1]: npm ERR! Linux 3.13.0-105-generic
2017-02-21T22:12:28.283226+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-02-21T22:12:28.283500+00:00 app[web.1]: npm ERR! node v7.5.0
2017-02-21T22:12:28.283773+00:00 app[web.1]: npm ERR! npm  v4.1.2
2017-02-21T22:12:28.285052+00:00 app[web.1]: 
2017-02-21T22:12:28.286543+00:00 app[web.1]: npm ERR! missing script: start
2017-02-21T22:12:28.286758+00:00 app[web.1]: npm ERR! 
2017-02-21T22:12:28.286908+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2017-02-21T22:12:28.287072+00:00 app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
2017-02-21T22:12:28.298997+00:00 app[web.1]: 
2017-02-21T22:12:28.299253+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-02-21T22:12:28.299393+00:00 app[web.1]: npm ERR!     /app/npm-debug.log

I double checked the dist/package.json and a start script is present. Any ideas why this error may be occurring?

NuroDev avatar Feb 21 '17 22:02 NuroDev

I don't use Heroku, but are you sure that package.json got deployed to Heroku? Is there any way to see that?

silvenon avatar Feb 22 '17 11:02 silvenon

I have been looking into this more and I found the issue. The Heroku app by default tries to build from the root directory. Makes sense about the no script error now 😂. Need to find a way to point Heroku to build from a sub directory or set the build directory. If I do i'll make a PR.

NuroDev avatar Feb 22 '17 11:02 NuroDev

If you see the very end of that recipe, it says that you should deploy only dist, so I'm guessing that should be your root. Is that possible to do?

silvenon avatar Feb 22 '17 11:02 silvenon

I don't have a huge total use time with Heroku, but from what I have been working out is that you can instead point it to a branch to deploy from. So best bet is to create a deployment branch and point Heroku to that branch to build from.

NuroDev avatar Feb 22 '17 11:02 NuroDev

Yeah. In any case it appears that modifications to the recipe should be made. If you'd like to submit a PR once you get it working, that would be great. The simpler, the better. 😉

silvenon avatar Feb 22 '17 11:02 silvenon