Deploying Heroku App
Deploying Heroku App
js App to Heroku
1. Create a Heroku account (free).
2. Install the Heroku CLI (Command Line Interface) to use the heroku command to create,
monitor, and deploy your Heroku app (usually requires internet connection).
3. In your package.json, specify the node script to run on the server (similar to the one
you would run in the command line locally, but use node instead of nodemon). To do
so, add "start" : "node <app-file-name>" to the "scripts" as seen on line
8 below:
4. Initialize your Heroku repository. Just like Gitlab, Heroku makes use of git to manage
your files. However, we need to create this repository first.
a. Open your terminal in your project directory (type ls to make sure your files are
there) and type git init to create the necessary files for managing the Heroku
repository.
b. For the first time you create a Heroku app, run heroku login to authenticate
your user/pass locally. This is a one-time step. Note that if you are using
Windows and get stuck at the login screen, you may need to use the Windows
Command Prompt instead of Git Bash. See Appendix at bottom of this document
for equivalent screenshots.
c. Run heroku create. This will tie your local repository to Heroku and allow you
to push your files.
d. Add your files (but not any node_modules - these will be installed on Heroku
using your package.json) with git add and then commit with git commit
-m “commit message”.
5. Push the repository to heroku with git push heroku master. A link will be printed
to the terminal once your site is online. This is the URL to your web service (and you can
also fetch from it!) To easily open within the current directory, run: heroku open.
Appendix: Screenshots using Windows Command Prompt
To find the Command Prompt: