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.
- Go to the NodeJS home page
- Click install to download the .msi installer package
- Run it and follow the instrucitons, you now have NPM (node package manager) and Node.js installed
- 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
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
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
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
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
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.
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.
how to call the html files and controllers
nice and simple explanation
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
fsdgfsdg
thanks
thanks so much!
Just wish to say your article is as surprising.
The clearness in your publish is just cool and i can think you are a professional on this subject.
Well with your permission allow me to take hold
of your RSS feed to keep up to date with approaching post. Thanks one million and please
continue the gratifying work.
arts and crafts for kids
How I can run it on PHP hosted server?
Great work Dude
You saved me hours of searching … Thank you !!
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.
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!!!
Sorry Larry, this tutorial is just for setting up the bare bones basics (meaning not NPM packages like Express). If you are looking for something more complex on these subjects I recommend Node.js in Action http://www.manning.com/cantelon/
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!
Thanks a lot for this. People often underestimate the value of simple, straightforward documentation.
Perfect, it’s absolutley work on me!!
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
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).
Can you please explain how…? I can’t find any clue here..
If you’ve installed the latest NodeJS and restarted your computer, it should just kick in.
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.
Had the same issue.
run successfully
thanking you for your tutorial
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.
thanks alot dude…the installation worked just fine
Simple and to the point. Wowwwwww
Great one . It works for me also :)
Run Successfully,,,
thanks for ur tutorial …
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
Hello Frnd,
Please let me know how to installed Node Js and how to run my test.js page..
please help me..
Nice procedure to install great dude
Thanks..it worked :)
Simply great……
Thanks! This article helped me a lot!
Thasnk
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”
:(
same here
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 !
i do appreciate your writing, I tried it and viola….ITS WORK, many Thanks
how stable it is to run nodejs on Windows? nice step by step. I can follow u well
Mostly stable these days other than the occasional package. As some of the packages use Linux libraries that aren’t available on Windows.
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.
Only way I’ve been installing on my Windows computers is through the default Node.js installer package. They do have a .exe and some other fun files on Node.js’s download page http://nodejs.org/download/ (try at your own risk though).
The node.exe file doesn’t seem to be an installer of any kind. It just opens its own command prompt.
A bit surprised it seems to simple and yet useful.
Created the greatest articles, you have.
The honesty of your posting is there for all to see
Hey hey hey, take a gander at what’ you’ve done
That’s a posting full of insight!
Information is power and now I’m a !@#$ing dictator.
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
worked in first try..superb..thanks a lot.
thank you so mush….
worked perfectly on the first try – great tutorial! thank you
Thanks for the clear instructions and the “hello world” test – it was all I needed – cheers!
you are a god. thank you!
I have an error
“node is not recognized as an internal or external command”
I was getting that until I restarted my computer. It sounds like your terminal is missing the “node” namespace. Did a restart fix it?
Thanks for your tutorial, it helped me to setup Node.JS on my windows machine!
Thanks, lol i tried installing it using cygwin not even realizing it was the old way. Downloaded like 500MB+ stuff doing that haha
Thanks.
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
I also got this error. How could I fix it? Anyone help?
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!
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.
Where can i find a good documantation about how to using node.js ?
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.
Thank you so much. I really appreciate. Thanks for your suggestions. :)
Thank’s for your great totrial. It helps me so much :)
No problem, installing Node for the first time can be a pain.