Tuesday, August 30, 2011

Developing node.js applications in WebMatrix and testing in IIS Express on Windows

In my last few posts I introduced the iisnode project and talked about specific aspects of hosting node.js applications in IIS 7.x on Windows:

Hosting node.js applications in IIS on Windows
Integration with the URL rewrite module

Running node.js express applications

In this article I am showing how to use the WebMatrix development environment to develop node.js applications and test them in IIS Express using the same iisnode module. WebMatrix is a free, lightweight, Windows based development environment for web application development using a variety of web technologies.

Setting it up

First you need to download and install WebMatrix (free). The download will also include IIS Express, a lightweight version of IIS specifically designed for development purposes.

Next you need to download a recent x86 build of iisnode. Unzip it somewhere on disk.

Note: if you are running 64 bit Windows, you still need to download the x86 build of iisnode, since IIS Express only ships in 32 bit version. 

Now install iisnode by calling the installation script from the command line with administrative privileges:

  • on a 32 bit Windows system:
install_iisexpress.bat
  • on  a 64 bit Windows system:
%systemroot%\syswow64\cmd.exe /C install_iisexpress.bat

If everything goes well, you should see successful installation confirmation:

image

Take note of the samples directory to use it from WebMatrix in the next step.

Start up WebMatrix

Start up WebMatrix. When prompted, choose “Site from folder”:

image

Enter the samples path that was shown in the last step of iisnode installation:

image

You can now explore and modify all node.js samples that came with iisnode installation in WebMatrix:

image

Right click on index.htm and choose “Launch in browser”. IIS Express will host the samples web site and you will be able to access the node.js sample endpoints exposed from IIS Express:

image

What did just happen?

WebMatrix with IIS Express gives you a lightweight, free development stack for node.js applications on Windows. IIS Express allows you to exercise the same set of features iisnode exposes in a regular IIS installation, including URL rewriting module.

So where can I get iisnode again?

Everything you need to get started is at https://github.com/tjanczuk/iisnode. Make sure to check out the samples. Feedback welcome!

2 comments:

  1. Awesome! Thank you for creating this project.

    ReplyDelete
  2. thanks for creating this beginner's guide. I want to know that how can one update the node.js version? The current WebMatrix and IIS express ships with v0.6 while the current stable node.js version is v0.8, and there are quite some changes in the latest release. Please let me know how to update node.js.

    Regards.

    ReplyDelete

My Photo
My name is Tomasz Janczuk. I am currently working on my own venture - Mobile Chapters (http://mobilechapters.com). Formerly at Microsoft (12 years), focusing on node.js, JavaScript, Windows Azure, and .NET Framework.