Wednesday, December 7, 2011

Install Node.js in Windows

If you're like me you are forced to use windows at work, and I know that is quite a few people.  I'm not going to get into why that's a bad thing or any of the pro-linux talk, it is what it is.  I'm also not going to get into the fact that if you're a gamer chances are you're running windows at home (although I hope changes all that) as linux isn't the preferred os for gaming, not that it isn't better or worse, again: it is what it is.  For the record, I am pro-linux.

For most of what this blog is about is based on node.js.  So we need a way to install and use node.js in windows.

Let's proceed to

That's the windows msi installer, the one we want.  By the time you read this they might be on v1.0.0 for all I know, but I'm guessing it'll be about the same.  Currently the 0.6.5 is ~3 MB.  Let's run it.

And click "Next".

We're almost done.

Let's open up a text file in notepad and copy/paste this test node.js application:

        res.end('Hello World!');

Save it as server.js to your root directory C:\ or whatever it may be.

So now we run in a command prompt/powershell:
You can bring that up with Windows Key + R and typing in CMD

Your node.exe is located usually <root>\Program Files\nodejs\node.exe
so probably: C:\Progra~1\nodejs\node.exe

node.exe c:\server.js

The server.js is the one I had you create and save to your root directory earlier.

If it's your first time doing this you'll end up with:

Click "Allow access"

Now open up your browser (here I am using Chrome 17)

And let's see if our server.js is running by following the link or typing it in:


If your results look something like this you've done it!

Node.js is fully installed, running, and tested.  Awesome.

No comments:

Post a Comment