Deploy Node.js to Heroku
Contents
I used the folder “Desktop/restful” as my REST API folder.
First, create a free Heroku account.
Then, create a new app “morning67890” on Heroku.
Download the Heroku Command Line Interface(CLI)
|
|
I copyed all files of my RESTAPI from my old RESTAPI folder to the folder “Desktop/restful”.
Under “Desktop/restful” folder:
|
|
Check node version:
|
|
The noder version shoulde be higher than 10.
Check npm version:
|
|
Check git version:
|
|
Make sure the node.js is runing locally without problem
|
|
Try to run my API:
|
|
I should install swagger-ui-express.
|
|
Try to run my API again:
|
|
Then install joi:
|
|
After installed swagger-ui-express and joi, server.js runs successfully.
Deploy the app
Create an app on Heroku. You can careate on the Heroku web site or from local computer.
To create the new app locallly, open Terminal and type:
|
|
To delete/destroy a Heroku application:
|
|
Create a new git repository - morning67890 from heroku website
Open Terminal and type:
|
|
Deploy your application:
|
|
That is it. If it doesn’t work, check logs to find out the reasons:
|
|
Author Susan
LastMod 2022-02-03