Nodejs on Windows

This turned out to be easier than expected.

Step 1: Download node.exe

Get it from http://nodejs.org/#download and put it somewhere in your path e.g. c:\node

Step 2: Install git

Get it from here and install into your windows console if you want to use the windows command prompt instead of bash

Step 3: Install NPM (node package manager)

This one is a little more involved.  Run the following commands (ref: http://npmjs.org/doc/README.html#Installing-on-Windows-Experimental)

git config –system http.sslcainfo /bin/curl-ca-bundle.crt
git clone –recursive git://github.com/isaacs/npm.git
cd npm
node cli.js install npm –gf

Step 4: Install express

Express is a really cool web framework for nodejs and should simplify your web development considerably.  This is of course optional, but here are the steps anyway.

create a folder for your app e.g c:\projects\myapp

cd c:\projects\myapp

npm install –g express

node app.js

Now, if you visit http:/127.0.0.1:3000 you will see a 500 error page because you are missing a dependency.  npm install –d should fix it but that threw all kinds of errors in windows “couldn’t unpack blah blah”, “unknown error blah blah”, “out of memory blah blah”…  Fortunately, running this command downloaded the missing dependency (jade) into the temp folder, on my machine it was at C:\Users\Emad\AppData\Local\Temp\npm-1320719310093\1320719310093-0.5456247869879007\contents\___package.npm\package (if it is not there, you can get it from https://github.com/visionmedia/jade)

I copied the content of that folder into C:\node\node_modules\jade and that took care of the problem.  Now visiting http://127.0.0.1:3000/, I see

Step 5: Install linux in a Virtual machine

Yes, you read that right.  It is just much simpler to work with node stuff on linux.  Everything just works.  It seems like on windows, you are constantly swimming upstream.