node.js on Windows
By Dan Baker, published 2010-09-09
I finally broke down, and setup node.js on my Windows XP box. The following is what I recommend doing: Walk through the page at github. My comments on that page are as follows:- download cygwin
- Visit the site cygwin
- Click on the link in the top/right corner labeled "Install or Update cygwin now", and download the program called setup
- install cygwin on your Windows box
- run setup.exe (Wizard will show)
- Cygwin Net Release Setup Program (Next)
- Choose A Download Source (Install from Internet, Next)
- Select Root Install Directory ("C:\dev\cygwin" is where I put it, Next)
- Select Local Package Directory ("C:\dev\cygwinPackages" is where I selected, Next)
- Select Your Internet Connection (Direct Connection is what I used, Next)
- Choose A Download Site (I selected one near the top that sounded familiar (xmission), Next)
- Wait for things to download...
- check several options (see the list on the github page)
- Expand "Devel" (long list expanded)
- devel -> gcc-g++
- devel -> git
- devel -> make
- devel -> openssl-devel
- devel -> pkg-config
- devel -> zlib-devel
- Expand "python"
- python -> python
- Finally, the install starts. This will take a long time (I left and came back later)
- run cygwin (Start -> Cygwin -> Cygwin Bash Shell) or the "Cygwin" shortcut installed on the desktop
- clone node.js repository. Visit nodejs change log to read about recent versions
- $ cd ~
- $ git clone git://github.com/ry/node.git
- $ cd node
- $ git fetch --all
- $ git tag Note: This step shows a list of various tagged versions. You will want the last listed version, I think. That version for me was "v0.2.0"
- $ git checkout v0.2.0
- build node.js
- $ ./configure Note: this took me about 45 seconds, and reported: 'configure' finished successfully
- $ make Note: this took a me about 5 minutes, and reported: 'build' finished successfully
- $ make install Note: this took about 1 second, and reported: 'install' finished successfully
- setup DNS
- $ vim /etc/resolv.conf Note: this is suppose to start a text editor with the resolv.conf file -- but I didn't have "vim" or "vi" installed...
- alternate method of editing files:
- From windows explorer, go find the folder you installed cygwin to. Right-click on the cygwin short cut on the desktop, "properties" and click "Find Target..."
- There should be several folders here, like: bin, dev, etc, home, lib ...
- The "home" folder will have a sub-folder with your named account. Under that folder is a folder called "node", which contained the files you checked out from git
- The "etc" folder is where we want to create a file called "resolv.conf"
- Use notepad, and paste in the following nameserver 8.8.8.8 nameserver 8.8.4.4
- Restart cygwin:
- $ exit
- Run cygwin again
- Create a node.js application (http server app)
- Visit nodejs
- Copy the entire sample text:
- Paste it into .../cygwin/home/[USER]/node/example.js
- Start this node.js app
- $ node example.js Note: Should see message: Server running at http://127.0.0.1:8124/
- Use the running node.js app in a browser
- Open browser to: 127.0.0.1:8124
- See "Hello World" in your browser!
- Stop node.js by pressed Ctrl-C
var http = require("http"); http.createServer(function (req, res) { res.writeHead(200, {"Content-Type": "text/plain"}); res.end("Hello World\n"); }).listen(8124, "127.0.0.1"); console.log("Server running at http://127.0.0.1:8124/"); - $ exit Note: exit cygwin
- Re-run Setup.exe The setup program used to install cygwin (see Step#2 above)
- run setup.exe
- Cygwin Net Release Setup Program (Next)
- Choose A Download Source (Install from Internet, Next)
- Select Root Install Directory (leave where you installed last time, Next)
- Select Local Package Directory (leave from previous install, Next)
- Select Your Internet Connection (Direct Connection, Next)
- Choose A Download Site (same as last time, Next)
- Wait for things to download...
- Select Pages (This is the MAIN page)
- In the "Search" box, type "curl"
- Expand "web", and next to "curl: Multi-protocol file transfer command-line tool" click on "Skip". It will change to a release number (7.20.1-1 in my case) with "Bin?" checked and "Src?" not checked
- Other things I installed: vim, curl,
- Run cygwin again
- Installing "NPM" (If you want to)
- says to do the following: curl http://npmjs.org/install.sh | sudo sh (this won't work in cygwin)
- DO: curl http://npmjs.org/install.sh | sh (Always just ignore the "sudo" command)