How to Deploy a Node JS app on heroku Properly Fix h10 errors

Опубликовано: 20 Октябрь 2024
на канале: roktech
1,944
16

https://devcenter.heroku.com/articles...

-First: Have an account (heroku account);
-confirm the installation of git npm and node
-brew tap heroku/brew && brew install heroku (install heroku using your terminal)
-make sure you have a Procfile in your app project directly
web: npm app.js (Your Procfile should contain that)
-In your code, make sure the port is process.env.PORT || port (where port is my local 3000);
//Listening port;
const port = 3000;
app.listen(process.env.PORT || port, function(){
console.log('Listening on port' + port);
});

-heroku login (Login to your heroku account both browser and terminal)
-npm init, git init, add, commit
-heroku create
-git push heroku main
-heroku open
-heroku logs —tail