Install Node.js on Windows

install node js windows

Tonight I was trying to install Node.js on Windows and couldn’t find any straightforward documentation. Reason is each new release of Node.js has multiple ways it can be setup. For instance, older versions required Cygwin and some people use a .exe file. None of these methods are optimal, so I’ve written a tutorial on how to install Node.js own Windows and test it in 6 steps with less than 10 minutes of your time.

Edit (10/19/2012): The below information is for Node 0.6 (including the code test sample). If you want to install the latest version just follow these simple steps and you should be good to go.

  1. Go to the NodeJS home page
  2. Click install to download the .msi installer package
  3. Run it and follow the instrucitons, you now have NPM (node package manager) and Node.js installed
  4. Reset your computer to get everything working in your command-line interface (CLI)

Windows Installation Instructions

To install Node.js on Windows is quite easy. You’ll just need to grab an installer package from their website and run it. Well it isn’t quite that easy, but its close.

Download node.msi Windows Installer

download node js

Go no Node.js‘s website and download the Windows .msi installer file. This is literally all you need setup everything.

Run node.msi Windows Installer

node js msi installer

Run Node’s .msi file from anywhere on your computer. An installation window will appear. All you need to do is agree to and click okay on everything. If your Node.js install is corrupted, you can re-run this file and select repair to fix it.

Reset your computer

reset your computer

This is the step that everyone forgets. Once you’ve installed the .msi file you need to reset your computer. Failure to do so will prevent you from using Node in your command prompt. Wondering why? You need to flush Windows since its adjusting registry files and who knows what else under your computer’s hood.

Post Install Node.js on Windows

Just because you’ve installed Node.js doesn’t mean it works. In the next three steps, we’ll quickly walk through creating a test file and running it.

Create a Test File

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');

To make sure your Node.js install works on Windows, create a simple hello world script with the above code. Call it test.js and store it somewhere easy to access on your computer. A location such as c:\node\test.js will make your life easier when accessing the file via Windows Command Prompt. If you use a different location you’ll have to adjust the following examples.

Run Windows Command Prompt

Running windows command prompt to test node.js

Run your Windows Command Prompt and relocate to test.js’s folder. Here you’ll need to run node test.js. Running this line of code causes Windows to activate the file and output a message.

Verify Install Node.js on Windows

node js hello world

You probably noticed that running node test.js output a message identical/similar to Server running at http://127.0.0.1:1337/. To verify node is working correctly leave your command prompt running in the background, then copy and paste http://127.0.0.1:1337 into your browser. This should display an image similar to the above picture. If it still isn’t working walk back through the above steps or leave a comment below for more help.

If you made it through the above steps there is nothing left to install Node.js on Windows. Your computer should run it fine and no further configuration is necessary.

70 thoughts on “Install Node.js on Windows”

  1. Thanks for this, I came across so many other examples with instructions mixed form different platforms and stopping short of the steps to verify.
    Nice to see a straightforward and easy to follow guide.

  2. Great clear and precise instructions to install node js. To many idiots out there that think they know what they are doing but really they don’t. This is a job well done

  3. You are my hero. I looked at numerous attempts to teach this simple concept of installing node.js, from countless know-it-all geeks, and all of them are just too smart to understand the concept of simple instructions.

    You hit the nail squarely on the head and delivered a superb tutorial! Much thanks.

    It never ceases to amaze me how people who have been trained in the most advanced subjects loose sight of how to communicate with humans like me. After all, I am still a much superior machine when compared to any modern computer. So, why is it that my language is so sadly overlooked by those who seem to master, and understand, complex machine languages?

    That is the real mystery of these times we live in!

    I’m glad people like you are still around to teach humans how to be masters of machines, rather than how to teach machines to be masters of humans.

    Thanks again.

  4. still misses the point as all these tutorials do: Installing Nodejs and Express.. which directories? where do you put your templates after the install? That is, your nodejs is for running web applications!! Static pages aren’t even mentioned by these folks… Common sense never prevails… Which npm, The commands you use will influence what and where something is installed. Everyones environment is different but… this makes believe that everyone is the same. Windows screws things up esp on 8 which has endless problems. For the most part you will get a page can not be displayed… and you will be wondering what happened.. has nothing to do with firewall or permissions … it has to do with where your working directory is after a default install of node and express!!!

  5. Thanks you so much for this wonderful newbie step-through. I had gone to other sites all of which forgot to mention the crucial restart Windows step. Hello World!

  6. The reset step is something vital but you dont explain what to reset or how. We are talking about Windows, right? Im not Windows expert, but I guess Im not only one who have no clue whats reset in Windows world. If we were talking about router or some other chip, it would be clear. But generally, you dont “reset” PC. It sounds quite wild to reset when just installing software… O_o

    1. Like it says reset the computer plain and simple. You need to rebuild the command prompt task list. Pretty much you add the necessary “node” and “npm” tasks when your computer reloads from scratch (as depending on how these are installed are only loaded at boot).

    2. By “reset” I think the author just means “reboot” (shutdown the operating system and then start it again).

      Also, there really isn’t anything magical about rebooting. Perhaps the author encountered a bug with an older version of node (this post is qute old now) or perhaps already a command prompt window open during the installation (which would not have had its PATH environment variable updated automatically without closing and relaunching it).

      In case you’re curious, the MSI appears to have been created using WiX and you can see the source here.

  7. In all honesty, thank you so much!! It was my first time setting up a server and this is totally like the holy grail of node.js installation tutorials. It’s really to the point and it works!

    Just a heads up in case anyone encounters the following error on cmd: “node is not recognized as an internal or external command”. Simply type SET PATH=C:\Program Files\Nodejs;%PATH% on cmd and you’re good to go.

  8. Hi

    i have created a small js file with following code to test stream or say request.pipe functionality
    var http = require(‘http’);
    http.createServer(function(request,response){
    response.writeHead(200);
    request.on(‘data’,function(chunk){
    response.write(chunk);
    })
    request.on(‘end’,function(){response.end();}) ;
    }).listen(8888);

    But how can i test it using command prompt like i need to pass data like they do it using
    $curl -d “hello” http://localhost:8888 (how to do this using windows command line )

    Any help with this would be great

    Thanks in advnace for your support

  9. Hi,

    I have followed all the steps above. When I run the cmd, it shows that “Server running at http://127.0.0.1:1337/“, but when I copy the IP to the browser, the result is “503 Service Unavailable Failed to connect to server 127.0.0.1”

    :(

  10. Thanks for the detailed steps. I was trying for more than 2 hours without restarting my machine. After I did that, as mentioned in your tutorial, everything started working fine. Thanks a lot !

  11. Is there a manual, non-msi method? On my Win 7 work laptop the msi file refuses to run, something IT installed seems to be preventing it.

  12. It’s an wonderful tuts. It works for me that I can see the output Hello World in browser. But an issue worries me that is when I try to run node test.js in command promt, I got the following error/message (I do not what it is actually) that is,
    Error: listen EADDRINUSE
    at errnoException (net.js:901:11)
    at Server._listen2 (net.js:1039:14)
    at listen (net.js:1061:10)
    at net.js:1135:9
    at dns.js:72:18
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)
    at node.js:901:3

    Could you tel me why it comes.

    Many thanks for this wonderful tutorial.

    Shimul

  13. Thanks, lol i tried installing it using cygwin not even realizing it was the old way. Downloaded like 500MB+ stuff doing that haha

    Thanks.

  14. I was getting little ‘Windows Script Host’ JS runtime error popup when running:

    node node.js

    Error: Object expected
    Code: 800A138F
    Source: Microsoft JScript runtime error

    To get rid of it add the .exe extension:

    node.exe node.js

  15. Thank you very much for this tutorial. I struggled for hours and hours before finally arriving here. I tried using Cygwin Command to install NodeJs and I cannot even start talking about how many times it crashed during the MAKE command. I almost gave up until I found your blog and followed the instructions with ease and ended up having a smooth running server on my machine. I have one question now though:

    You mentioned that older versions required Cygwin. Does that mean we do not need Cygwin on our PC anymore to have the NodeJs? I have Cygwin installed and if I don’t really need it, I guess I should remove it or something. Please help me with this question and I will appreciate so much!

    Thank you again for the awesome tutorial!

    1. All you should have to do is download go the the NodeJS home page and download the installer (see edit below first paragraph). I would avoid Cygwin (at all costs) on Windows if you don’t need it. For NodeJS it isn’t required.

    1. That’s a great question as a majority of the documentation is out of date or terribly written. Even most of the books that have been released feel fairly rushed. The only reliable place you can find information is http://nodejs.org/api/ at the moment. Avoid most online tutorials, as they give incorrect information.

      On the other hand I do recommend NodeJS In Action. Not trying to promote my publisher necessarily, but it really is a good book and written by the guy who created Expression for Node. Searched through Amazon to look for alternatives to recommend and can’t find any others I’m comfortable with suggesting.

Leave a Reply

Your email address will not be published. Required fields are marked *