This site is a preview of the curriculum for our Summer 2018 bootcamp in Burlington, Vermont. As we continue our preparation, courses and lessons will appear and disappear; we will rename, rearrange, clarify, and obfuscate as needed... Please consider this a work in progress and keep checking in.

 Learn to Code with JavaScript:
Hello Node


Build a simple 'Hello World' application in NodeJS and deploy it to Heroku.


Hello, Node!

In this lesson you will create a trivial web application in NodeJS and deploy it to Heroku, where it will be visible to everyone on the Internet.

Hello, File!

  • In your Terminal, make a directory called hello_node with mkdir hello_node

  • Immediately enter the directory with cd hello_node

  • Launch the Atom text editor in this directory with atom . (pronounced "Atom Dot")

  • Inside this directory make a file named index.js and fill it with the following code:

var http = require('http');
var port = process.env.PORT || 5000;
http.createServer(function(request, response){
  response.write('Hello from NodeJS!');

Hello, Localhost!

  • Go back to the Terminal and run the app with node index.js

  • Visit http://localhost:5000/ to see it running on your own computer.

Hello, Procfile!

A Procfile tells Heroku what commands to run when it launches your app.

Go back to Atom and create a file named Procfile (there is no extension on this filename) and fill it with this:

web: node index.js

Note that the code after web: is exactly what you typed to run the app locally.

You also need a package.json file. Create it in Atom and fill it with this:

  "name": "hello-node"

Hello, Git!

Now make a git repo for your app.

Remember to press CTRL-C to stop the server!

git init
git add .
git commit -m 'first commit'

Hello, Heroku!

Heroku uses git for its deploys. Whenever you push a new version of your git repo to Heroku, it automatically deploys the app.

heroku create
git push heroku master

If all goes well, you will see a URL on your console, something like this:

remote: deployed to Heroku

Visit this URL in a web browser using copy-and-paste, or use this handy shortcut from the console:

heroku open

High Five!

If you are working with a partner, give them a high five.

If you are alone, give yourself a high five.

high five

You deserve it!


Hello, You!

Now go back to Atom, and modify the app so instead of saying "Hello from NodeJS!" it says something clever and personalized.

Once you've made the change...

  1. test it locally
  2. add the changed file to git and commit the change
  3. re-deploy to Heroku
  4. reload the web page and read your new message
  5. give yourself a high five!


Some other Node tutorials:

see also


comments powered by Disqus