Installing NodeJS on Windows

Until very recently, when I wanted to program in NodeJS, I did so on a Ubuntu VM running on my Windows machine. Firstly, because in the beginning, NodeJS didn’t run on Windows. Latterly, because to install it on Windows was four MSI files and to install it on Ubuntu was a case of running “sudo apt-get install NodeJS”. There’s no contest there is there?

However, yesterday I spent the day with Mark Rendle as he was in Dundee as part of his DevExpress sponsored speaking tour of the UK. During our many geeky conversations he mentioned Chocolatey to me and told me I should take a look, “it’s apt-get for Windows”, he said.

So I took a look, and right enough, to install “stuff” with it couldn’t be easier. Of course, first of all you have to install Chocolatey itself; turns out that’s a breeze though. Simply run the “cmd” command as Administrator and drop into Powershell (yes I know, bear with me though). Then from the Powershell prompt run:

Set-ExecutionPolicy Unrestricted

After that, run:

   1: iex ((new-object net.webclient).

   2:    DownloadString(""))

And “Bob’s your uncle”, that’s Chocolatey installed. Now you can run Chocolatey from, either Powershell, or an ordinary command prompt. Having installed it, we can use it to install a whole load of packages, including NodeJS. To do that, open a command prompt and type:

cinst NodeJs

then stand back and watch the magic happen (cinst is short for Chocolatey install by the way).

Having installed NodeJS, it’s time to test it with the time-honoured “hello world!” application so open up your favourite editor and type the following code:

   1: require('http').createServer(function(req,res){

   2:     res.writeHead(200,'text/plain');

   3:     res.end('Hello World!');

   4: }).listen('8080');

Now save the file, call it server.js, and run it by typing:

node server.js

at the command prompt. Now we can connect to localhost:8080 and check that everything is working okay:


Which it is, so that’s cool. And that really is all there is to installing NodeJS (and all the other cool packages available on, so what are you waiting for?! Come on in, the NodeJS water’s fine! Smile

This entry was posted in NodeJS. Bookmark the permalink.

10 Responses to Installing NodeJS on Windows

  1. Worked like a charm sir. Thanks for the post!

  2. Rob says:

    I think chocolatey is awesome, but then again, I’m biased!

  3. Gary Short says:

    You are welcome Scott and Rob, yeah, you’re biased. 🙂

  4. Sampsa says:

    Works well for me, but the version is a bit old (0.6.0 compared to current 0.6.3), any idea when and if this gets updated now that NodeJS has it’s own Windows installer?

  5. ferventcoder says:

    @Sampsa – it’s up to date now. Now that there is an installer there can be a second chocolatey package to support the msi.

  6. T says:

    Thanks a mil man, that was so easy

    You deserve a chocolate now, ehehe

  7. Pingback: KnowYourStack - What is Chocolatey

  8. wheresrhys says:

    Fantastic post (wish I’d foudn it before I installed mongodb too).
    One important point though is that the package should be used (there are other packages available, but this is the only one to include npm)

  9. decoder says:

    Tank you very much for this excellent info

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s