Easy step-by-step guide to deploying on Heroku

Deploying on Heroku can be tricky — as a new user, it’s hard to know exactly what steps you should take and there are many pitfalls. Here’s a step-by-step guide to deploying an existing project via the Heroku CLI.

Signing Up

First, visit Heroku.com and sign up for a new account (or follow this link). It’s pretty easy, here are the fields you’ll need to fill out:

Creating Your App

Once you have your account, click the ‘New’ menu in the upper right corner and select ‘Create New App’

Now, simply name your new app! Don’t worry about adding a pipeline, that’s a different method of deployment than the CLI we are using.

Deploying Your App

Note that this next step requires Homebrew. Next you’ll head to the terminal, and navigate to your existing application folder (the root folder where your git was initiated). Now, copy and paste this:
brew tap heroku/brew && brew install heroku && heroku login

A window will pop up — since you’re already logged in to Heroku, you should be able to simply move through this screen by clicking “login". That was easy! Now Heroku is installed and you’re all logged in.
The next step is to add the Heroku remote to your git: enter the following into the command line:
heroku git:remote -a

Where is the all-lowercase name you picked .
Now you’ll push your existing code to the Heroku remote:
git push heroku master

Now you can sit back and watch it compile on Heroku! When it’s complete, you should be able to visit your hosted project by visiting .herokuapp.com

Common Pitfalls

Ruby Version Isn’t Supported

This is a relatively simple fix — go to the terminal and type
rvm install 2.4.5 && rvm use 2.4.5

Then head to your Ruby Version file and update that to 2.4.5. You’ll also want to head to your gemfile and update the Ruby version there to 2.4.5, delete your gemfile.lock, and run
bundle install

Then you can try pushing to the heroku master again!

Node and/or NPM Version Not Specified

Delete your package-lock.json and edit your package.json file to include:
"engines": {
"node": "<your node version>",
"npm": "<your npm version>"

You can find your node and npm version by typing
npm list

node -v


That should do it! If you are deploying and run into any other pitfalls, let me know in the comments and I will update the guide with a fix!

Link: https://dev.to/lucysuddenly/easy-step-by-step-guide-to-deploying-on-heroku-3m9p