Building your first node.js app - Part 1: Installing node on Windows 7 postComments
Our application is going to allow a web surfer (client) to populate a list of todo items for his profile. We will be authorizing the user, and displaying a public profile page with all of the users todo items. Only the user will be able to perform CRUD **operations on the todo list.
I will be building the application on my local machine, but you can also find node.js hosting out there in the wild. (see google). Now my machine is a windows 7 box, so I will be going over the steps to installing node on that platform using that platform. Unfortunately you will need to install a nix-like environment like cygwin on your windows machine to use node. You will also need Python to actually build the node binary. The steps to installing on a nix environment are actually fairly similar to the cygwin process, but I will not be covering them. In addition, on Windows 7/Vista there are some additional troubleshooting steps that need to be taken to get node to build successfully.
Step 1: Install Dependencies
UPDATE: joyent (who employs Ryan who created node) has posted a great tutorial to get node up and running with cygwin. This would be a great place to start if my directions don't work for you.
Download and install cygwin . Make sure to add:
Step 2: Build Node
Open a cygwin prompt.
Run the following sequence of commands to download and extract node.js:
wget http://nodejs.org/dist/node-v0.4.8.tar.gz tar xvzf node-v0.4.8.tar.gz cd node-v0.4.8
Time to install. First we need to run the configure tool.
If configure fails for you like it failed for me, you will have to take some additional steps. After poking around for a bit I found another great article on installing node.js on windows which has some advice for dealing with node.js installation problems. Here is what worked for me:
- Exit all Bash shells
- Launch C:\Cygwin\bin\ash as an Administrator
(Vista users) Edit line 110 of c:\cygwin\bin\rebaseall to say:
sed -e '\=/sys-root/mingw/bin=d' -e '\=cygwin1\.dll$=d' -e '\=cyglsa.*\.dll$=d' -e 's=^=/=' >"$TmpFile"
- Run /usr/bin/rebaseall
With that out of the way, it is time to retry the build process. Open back up your cygwin prompt and cd to the node src dir and enter the following commands.
./configure ./make ./make install node -v
Still with me?
If you are getting stuck on the configure step, be sure that you grabbed all the required packages and install using the setup.exe you initially used to install cygwin. Otherwise, you can visit this article on installing node.js for windows to get some more possible tips for dealing with your installation headache.
To be honest, the installation of node.js on Windows 7 with cygwin was actually a bit painful and it would be easy to get stuck on this step. If you can't get node running, I would recommend installing on a virtual machine running CentOS, Ubuntu or some other brand of linux. Next, in part 2 of my node.js tutorial, we will set up our webserver and get it responding to user requests.