COMP 20: Web Programming

Lab: Getting Started with the Server Side using Node.js and Heroku

Lab Objectives


Server-side development is a lot more involved than what we have been doing so far and requires a number of components and software including Node.js and MongoDB (database). You will be using a database in Assignment 3 but not in this lab.

For this class, we will deploy our server-side web application to Heroku. Why use Heroku you may ask? With Heroku, we do not need to worry about the server hardware, server configuration, and server maintenance. Server configuration and maintenance require an extraodinary amount of work --just ask my Web Enginering students what they had to go through when they were thrown into the fire to use Amazon EC2 (part of the Amazon Web Services family, or AWS for short). For a more elaborate discussion on Heroku vs Amazon AWS, see

Software Installation Option 1 (required for Windows, strongly recommended for Mac users):

Use the virtual machine (VM). You will also need to install the Heroku toolbelt on the VM on your own.

Software Installation Option 2: For Advanced Mac OS X Users

If you are a Mac user and choose not to use a virtual machine, install Node.js, Mongo DB, and the Heroku toolbelt via Homebrew: brew install node mongo heroku-toolbelt.

Software Installation Option 3: For Linux Users

Install Node.js using directions at Then, install MongoDB using directions at

Important Notes


  1. Create a Heroku account: (free)
  2. In order to use MongoDB via addon in a web application on Heroku, you will need to verify your Heroku account via of a credit card. You will not be billed. The reason for this is to verify that you are a human, and not a spammer. If you do not have a credit card or not comfortable with using one, an alternative option is to buy and use prepaid credit card.
  3. Follow the instructions at up to and including the "Provision add-ons" section. IMPORTANT: Be careful in the "Scale the app" section. I suggest you skip the section because if you are not careful, you will be billed and we will not be responsible for your actions!
  4. Please also read the README for the node-js-getting-started example on GitHub:
  5. The important step: modify the web application so that it serves a static HTML file. Create a static HTML file on your own and put it in the public folder. This static HTML file can be named anything that you want. Modify index.js so that it can serves the static HTML file when one accesses the route /lab8. Example: accessing https://[YOUR_APP_IDENTIFIER_RANDOMLY_GENERATED] on a web browser will render the static HTML file that you created. See for more details on how to serve static content with Node.js.

Submitting the Lab

Add me as a collaborator (using my email address mchow[AT]cs[DOT]tufts[DOT]edu) for your web application in Heroku. You can do this by logging on to Heroku, go to the dashboard for your web application, under "Access", click on the "Add collaborator" button, enter my email address, and click "Save changes".