Lazycoder

18Mar/1010

Getting started with node.js on Windows

The title is somewhat misleading. As of right now, node.js doesn’t run on Windows. You have to run it on some kind of *nix/BSD based system. But there is a somewhat low footprint way to run it and play around with it on your Windows box.

 

Step 1 – Download and install VirtualBox orVMWare Player. I chose VirtualBox. It’s free, and supports 64-bit guests.

Step 2 – Download The Turnkey Linux core appliance and unzip it somewhere. This handy little virtual machine is based on Ubuntu and give you a basic command line environment with networking.

Step 3 – Import the Turnkey core appliance into VirtualBox.

turnkey_step_1

turnkey_step_2

Choose the .ovf file in the Turnkey directory you unzipped earlier.

turnkey_step_4

Click next and review the settings, making any changes as you see fit. The defaults should work fine. Then click import.

turnkey_step_3

Once Virtualbox finishes importing the virtual machine, you can start it up.

Assuming your network is configured correctly, the virtual machine will grab an IP from your DHCP server and be ready to go.

turnkey_startup

Step 4 – At this point you can either SSH into the virtual machine or you can connect using the web shell at the address indicated in the startup screen. Initially you can connect using as the root account with no password. You are almost ready to start installing node.js. First type “apt-get update” at the command line to make sure you have all the latest package information.

Step 5 – Install the developer tools you need to get and build node.js. Node.js isn’t packaged as a binary, you have to build it from source. Luckily it includes it’s dependencies and is pretty easy to build. But first we need to get a compiler. Type “apt-get install build-essential” and hit return. A lot of text will fly past, if it asks you if you want to go ahead press “y”.

Step 6 – Install Git. Now you’ve got a compiler installed, we have to install git so we can fetch node.js from the repository. At the command prompt type “apt-get install git”. Once that is complete, type “apt-get install git-core”.

Step 7 – Clone the node.js Git repository. If you want to put node.js is a specific directory, go ahead and make it then “cd” into the new directory. At the command prompt, type “git clone git://github.com/ry/node.git“.

Step 8 – configure the source for building. type “cd node” and change into the node directory that Git created. Type “./configure”. You may see a few “fail” messages. Don’t worry about them.

Step 9 – Build node.js. Type" “make” at the command prompt. Get a sandwich or a nice cool drink. It doesn’t take very long, but it’s not very exciting unless the Matrix screensaver is your favorite screen saver.

Step 10 – Install node.js and start build applications. Type “make install” once the build is complete. Once that is complete,you can type “node” at the command prompt and you should see the standard help information fly by.

 

Building a node module or application is beyond the scope of this short tutorial. I suggest reading up at the Node.js site.

Share and Enjoy:
  • del.icio.us
  • DotNetKicks
  • DZone
  • Reddit
  • Digg
  • StumbleUpon
  • LinkedIn
  • Facebook
  • FriendFeed
  • HackerNews
  • Netvibes
  • Posterous
  • Tumblr
  • Twitter
Comments (10) Trackbacks (2)
  1. thank you. very usefull.
    I would add a point before step 4. Check your /etc/resolv.conf file and make sure that these two lines appear.
    nameserver 208.67.222.222
    nameserver 208.67.220.220

    they are the primary and secondary DNS for principal FAI. Without that apt-get install command will fail because it will be unable to resolve domain name.

    Thanks again.

  2. Excellent point phish. I didn’t run into that problem when I ran apt-get but it could come up.

  3. thank you. very usefull.

  4. Good job! You explained very clearly. It helped me! Thanks!

  5. when i type ./configure,I got error”could not configre a c++ compiler”,and type “make”,I got error “command not found”

    help!

  6. jj – You have to install the GNU build tools. See step 5.

  7. I followed the tutorial to the letter, but when I try to reach my node server on localhost, chrome says that the webpage does not exist. With https://192.168.1.101:12320/ I can reach my virtual linux and start any node source (it displays text like it should/sys.puts). I tried about 10 different server examples… none gave a response on http. I used ports 8000, 8080 and such…
    help me please!

  8. LuaJIT seems to do very well in the game of language benchmarks, but those seem rather un-realistic at times. I mean I would consider anything related to closures much more important (speed-wise), than any raw number crunching.


Leave a comment