Thomas Ardal

Entrepreneur and founder of elmah.io

Developing node.js applications in Visual Studio

I’m not much of a notepad programmer. I like having tools supporting me while developing software. That’s why I needed some software for my recent node.js endeavours. There’s some nice tools available, but I really wanted to be able to develop, run and debug node.js in Visual Studio. A quick sweep on Google led me to two VS extensions, both promising support for node.js inside VS: Visual Node and node.js Tools for Visual Studio. Visual Node is from redgate and looks really cool. The stuff is in beta at them moment and I expect it to become paid software. I decided to look at node.js Tools for Visual Studio which is open source but a lot less shiny. It’s in version 0.1 and that clearly showed. During the installation I got about three different cryptic error messages, one requiring me to install a service patch from Microsoft.

When finally installed, creating a new node.js project is easy:

![nodejs_1](https://thonodejs_1

When created a new project is added to the Solution Explorer, just as any other project type in VS:

![node_2](https://thomanode_2

The nice thing here is that the folder structure now reflects a node.js and not a default .NET application (with Properties, References etc.). Like NuGet provides the Package Manager Console, the node.js extension provides the Node Package Manager embedding npm. Installing new packages is as simple as installing a NuGet package:

![node_3](https://thomanode_3

http-server package installed. Success! Look how the folder structure represents this:

![node_4](https://thomanode_4

Great! Let’s code a bit of JavaScript:

Completely stolen from http://howtonode.org/hello-node BTW. Exiting moment: hitting F5 and accessing http://localhost:8000 in the browser. The text Hello World appeared. That’s easy, right? Next up: debugging! I set a breakpoint on line 6 and re-hitting F5. When visiting the URL in the browser, the following is happening:

![node_5](https://thomanode_5

The debugger actually stopped in line 6. Hovering variables also works:

![node_6](https://thomanode_6

I’m happy! If you have luck to install this extension, node.js development suddently gets a first class citizen in Visual Studio.

Show Comments