Installing the chat example on node.js + using git and npm


Yesterday was the first JavaScript Hack Night at the Stamford Innovation Center, and I proposed to the group we try setting up push notifications using node.js and We had a heck of a time getting it up and running, even having referenced installation articles and google groups about the matter, so I’m posting my findings here.

I feel compelled to point out, though, our friend Joe got a node.js example site up and running using the node windows installer and Microsoft WebMatrix in a matter of a few minutes. However, I don’t believe he had running.


After installing node, npm and getting from git, running “node app.js” for the chat example kept producing the following error:

    throw err;
Error: Cannot find module ''
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)


We were failing to install dependencies. The following combination of versions eventually worked for me:

node 0.8.7
npm 1.1.49 0.9.10

Step-by-Step Installation

Dependencies, Git and working directory

I was working with a clean Ubuntu install, so I had to first run the following:

sudo apt-get install g++ curl libssl-dev apache2-utils git-core
cd ~
cd ~/

Installing Node

Get node.js. This may take a while to build, depending on your system:

cd ~/
git clone
mv node node-0.8.7
cd node-0.8.7
git checkout v0.8.7
sudo make install

Installing npm

Grab a copy of npm; we may be able to grab a newer one:

cd ~/
git clone
mv npm npm-1.1.49
cd npm-1.1.49
git checkout v1.1.49
sudo make install

Version check

At this point, we should see the following:

>node -v
>npm -v
1.1.49 chat example

Let’s download and run the chat example:

cd ~/
git clone
sudo npm cache clean
npm install .
cd examples/chat
npm install .

Be sure to run both npm installs! It will install all dependencies for the chat application. We were failing to run the highlighted step.

Start the application

cd ~/
node app.js

You should see output similar to:

   info  - started
   app listening on

Now you can visit http://localhost:3000 in your browser and play with the chat application.

Let me know if you have any problems.

Share This!:
  • Twitter
  • Facebook
  • Digg
  • Reddit
  • MySpace
  • LinkedIn
  • Slashdot
  • Technorati
  • Google Bookmarks

No related posts.

blog comments powered by Disqus