Follow these steps to deploy your Express App to Heroku:
- Install Heroku CLI
Create Heroku Account and install the Heroku Command Line Interface tools. You can find step by step instructions on how to do that here. You'll need Git installed on our computer first but they cover that in the guide here.
2. Confirm Node.js version in package.json
Make sure your version of Node on your machine matches the version you have listed in your package.json file.
3. Create Heroku App Inside Terminal
Make sure you're inside your project directory via your computer terminal and type the following command:
$ heroku create
After Heroku has created your new app, inside your terminal you'll see it gives you a special URL you'll be able to access your app from after you deploy. It will usually be some weird string of words followed by .herokuapp.com.
You can also access this URL from inside your Heroku.com Dashboard.
5. Set Environment Variables
If your application has any environment variables, you'll need to configure those as Heroku environment variables by typing the following commands into Terminal:
$ heroku config:set YOUR_ENVIRONMENT_VARIABLE_NAME="enter variable value here"
6. Deploy to Heroku
Alright we're on the final step! Once you've configured all of your environment variables go and and enter the following command in your terminal:
$ git push heroku master
You should now be able to view your Express App online at your Heroku App URL. If you'd like a custom domain for your Heroku App read this guide.
If your app still isn't live, try updating your version of Node.js and NPM and seeing if that fixes the problem.