Node.JS and Heroku

Saturday, January 11th, 2014

I am following Node:Up and Running to learn about Node.JS and extending what I have gleaned from this book, and learned on the excellent Javascript courses at O’Reilly School of Technology, so that I can deploy the book example apps on a Heroku dyno.  I like the way the book is written, but there are some really frustrating gaps – thus far.  At least for a node.js n00b like me.

If you got stuck like me, here are some fixes.  Most of these stem from a) typos and b) I assume, earlier versions of EJS and Express.

Chapter 2 – Example 2-1. A test for the POST API

The twitter_test.js file fails.  This might be by design – but if you want to correct the test case then you need to fix the assert.strictEqual to equal res.send.  The complete file then becomes:

Chapter 2 – Examples 2-17 through 2-22.  Getting the Chirpie site to work.

First off, you need to install EJS.  Do so from where your project is – so in my case, run it in the ‘my app folder’ – see below.


In the node_modules folder you will see a folder for ejs.

What the book does not state is that the example code needs to be saved in files with a .ejs extension.  So index.ejs should exist in the views folder and chirp.ejs in the partials.  In addition, the body tag is no longer support so you need to break the layout of the page into the ‘top’ and the bottom’.

The folder structure, with files, now looks like this:

The content of the files is as follows:







Now when you run you should see the the Chirpe page with an input box.  Enter some text and hit ‘tweet’.  You should see each tweet (aka ‘chirp’) appear below as a comma-delimited string.