Deploying Demo

Setup a simple app (327)

At command line:

npm init
npm install express ejs --save
touch app.js
mkdir views
touch views/home.ejs
touch views/about.ejs

Deploy a simple app (328)

Install Heroku toolbelt

Built-in if using cloud9, installation required if using codeanywhere At command line:

wget -O- https://toolbelt. heroku.com/install-ubuntu.sh | sh

Login Heroku

At command line:

heroku login

Setup git

Ensure git is used in the directory

git status

If directory not in git repository

git init
git status

Add files or sub-directory to git

git add app.js
git add views/

Commit add

git commit -m "[message here]"

Update the app to Remote Site

Create URL for your app and add git remote heroku

heroku create
git remote -v

Create a start-up script:

  • Edit file package.json under "scripts"
    • Add comma after "test"
    • Add line: "start": "node app.js"

Add and Commit package.json to git

git add package.json
git commit -m "add start script"

Push codes in git master branch over to Heroku

git push heroku master

Useful Heroku commands

heroku help
heroku logs
heroku open