loading...

Easy step-by-step guide to deploying on Heroku

lucysuddenly profile image Lucy Suddenly Updated on ・2 min read

Heroku Logo

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:

Heroku signup fields

Creating Your App

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

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.

naming your app

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 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 your app name you selected at creation

Where your app name you selected at creation is the all-lowercase name you picked with no spaces.

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

and

node -v




Success!

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!

Posted on by:

lucysuddenly profile

Lucy Suddenly

@lucysuddenly

Site Reliability Engineer trans, she/her

Discussion

markdown guide
 

I ran into an error installing heroku using the command given

No available formula with the name "heroku"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

This worked as an alternative for me

brew install heroku/brew/heroku
 

Great starter guide!

For those using Docker, I would also recommend checking out this Deploying with Docker guide.

For those using Terraform, the Heroku Terraform Provider is fantastic for managing a number of applications.

 

Was just about to make research on this.
Nice one
Thank you!

 

No problem! Let me know if you hit any snags!