How to write Procfile for node.js heroku deployment using bin/www?
12,050
Solution 1
You should do:
web: ./bin/www npm start
This is what fixed it for me!
Solution 2
This is what I have:
- A file in the root directory of the project called
Procfile
(no file extension) - Inside the file, the first line reads
web: bin/web
- In the
bin
directory which is also located in the rood directory of the project, I have a file calledweb
and inside I havenode ./bin/www
(well I have more, but lets keep it simple). - there is another file in the
bin
directory calledwww
where I have the code to start the node server. - Both files in the
bin
directory needs to be executable, and you can set this by doingchmod +x file_name
Explanation for the Procfile
As mentioned above, in the Procfile I have this line: web: bin/web
where
web:
- is the name of the process, and needs to beweb
for Heroku to like you :)bin/web
- is the path to your file
I hope this helps :)
Author by
Brian Ly
Updated on July 19, 2022Comments
-
Brian Ly almost 2 years
I am trying to deploy a Heroku app, and I believe the procfile may be the reason my app is not deploying. I've tried multiple solutions including:
web: node ./bin/www web: npm start
There may be another reason my app is not working, but I want to make sure my Procfile is set up correctly
-
Brian Ly about 8 yearsHey thanks for your help. unfortunately my app is still not deploying, but at least I know the Procfile is set up correctly now. This is message I got in the logs: 2016-02-26T23:37:33.319462+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nodeguestbook.herokuapp.com request_id=9bb42708-6af6-4762-80cb-d7a770c733de fwd="97.90.145.90" dyno= connect= service= status=503 bytes=
-
David Gatti about 8 yearsWell yes, your app is starting, but there must be something wrong in your code. Go to the Deploy section of your app on Heroku, Scroll down and hit the manual deploy, you will get a console showing everything that is happening. There you'll see what is actually wrong.
-
Brian Ly about 8 yearsAlright cool thanks again for all your help! Im looking through the logs now hopefully i can figure out what it means.