5.9 Deploying Your Apps


Make port dynamic
app.listen(3000);

Command env is a list of the environment variables.
const port = process.env.PORT || 3000;
We still set 3000 if we are not on Heroku Server(where no env.PORT exists)


Start Scripts

{
"name": "node_web_server",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},

Then, we can use npm start to run the node server.js.


PUSH UP YOUR CODE UP TO GITHUB


Push up code to Heroku
heroku create
`git push heroku