How To: Debug Nodejs on Windows Server with Visual Studio 2013

Want to play with Nodejs on Windows Server. The following steps will help you configure nodejs on Windows Server and debug your application using Visual Studio 2013

Install & Test Nodejs

Navigate to and click install. Follow the instructions and try creating the example webserver app to verify nodejs is installed properly.

This simple web server written in Node responds with "Hello World" for every request:

var http = require('http'); http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(1337, ''); console.log('Server running at');

To run the server, put the code into a file example.js and execute it with the node program from the command line:

% node example.js Server running at

Here is an example of a simple TCP server which listens on port 1337 and echoes whatever you send it:

var net = require('net'); var server = net.createServer(function (socket) {
socket.write('Echo server\r\n'); socket.pipe(socket); }); server.listen(1337, '');

Tip: To quickly check if node is properly installed open the command prompt type "node" and hit enter. If node is installed you will see a prompt where you can enter JavaScript into the window. If node is not installed you will see the following message: 'node' is not recognized as an internal or external command, operable program or batch file.

Download and Install Node Tools for Visual Studio

NTVS is open source, and has taken contributions from the very start. Designed, developed, and supported by Microsoft and the community NTVS supports Editing, Intellisense, Profiling, npm, TypeScript, Debugging locally and remotely (Windows/MacOS/Linux), as well Azure Web Sites and Cloud Service.

The Node Tools MSI can be downloaded from:

Close Visual Studio and run the downloaded MSI and follow the instructions.

Test Debugging Nodejs Visual Studio Project

Open Visual Studio 2013 and try creating a new JavaScript project.

Visual Studio Nodejs Project Types

When you expand the JavaScript node you'll notice a new option for Node.js. There are 11 different types of projects to pick from. Let's create a starter node.js Express 3 Application. Pick a file system location, specify details and click OK.

When the solution is opened you may be prompted to install dependencies in the package.json file. Select yes to install dependencies into your development environment.

When you click play to start a debugging session with Visual Studio. You should be able to add breakpoints and debug your nodejs scripts.

Get in Touch!

Matthew Stark

Founder, Making Things Work

Let's talk about your project & how I can help! Reach out at the below coordinates.

Connect on Linkedin read more about Matt »

Top Tags