Before we start, go to Heroku.com and log in or sign up for an account (if you don't already have one).
You will also need the Heroku CLI tool, available from Heroku Dev Center
Heroku uses Git for source control, so make sure you have that installed as well. Git install documentation can be found here.
- Check that everything is installed
$ heroku -v
$ git -v
- Log in through the terminal within your project directory
$ heroku login
# Then enter your email and password for Heroku
- Initalize a git repository
Make sure to create a
.gitignorecontaining anything that you don't want pushed to Heroku:
node_modules, reference docs, sandbox files, etc.
$ git init
$ git add .
$ git commit -m 'Initial commit'
- Initialize the Heroku container
$ heroku create
- Set Heroku as Remote Repository
Go to your Heroku dashboard and open up the new Heroku container.
Scroll down to "Create a new Git repository" and grab the command to add this container as our remote repository:
$ heroku git:remote -a CONTAINER-NAME-12345
And then paste that command into your project directory terminal.
masterbranch of Heroku App
git push heroku master
- View Your New Application
Go to the URL provided when pushing to
master or just type
heroku open into the project terminal.
A Few Notes:
index.js, we've set
const PORT = process.env.PORT || 5000- Heroku will be using
PORT = 5000.
- Make sure that you have a
"start": "node index". Change
indexto whatever entrypoint you're using if necessary.