Mar
25
2012

Writing a first Node.js application on Windows

Plage de la Grande Anse du Diamant

I started some weeks ago to play with Github Hubot and hosted one version on Heroku to start learning about all those new technologies.

The next step was to go a bit onto Node.js and write a first small application.

First you need to download Node.js and install it on your machine. I downloaded the Windows version 0.6.14.

When Node.js is installed on your machine you should find it on the folder C:\Program Files (x86)\nodejs for 64 bits machines and on C:\Program Files\nodejs for the 32 bits.

Then start a PowerShell window and type “node -v” you should see v0.6.14.

Now start you preferred text editor and create a new file server.js and copy paste the code from the home page of Node.js

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

Go back to your PowerShell window and type “node server.js” which should display “Server running at http://127.0.0.1:1337/

Now run your preferred browser and enter the url http://127.0.0.1:1337/

nodejs

I went a little further following the Node Beginner site and created a first module.
To do so I used JetBrains WebStorm 3 which you can easily configure to run and debug your Node.js application.

You need to configure it this way

nodejs2

Then you can add a Run/Debug configuration for Node.Js

nodejs3

Finally you can run your Node.js application in Debug mode

nodejs4

and for sure hit the breakpoints and watch the values of your variables

nodejs5

Which will help during my learning of this new technology!

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About Laurent

Laurent Kempé

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect and certified Scrum Master.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent was awarded Most Valuable Professional (MVP) by Microsoft from April 2002 to April 2012.

JetBrains Academy Member
Certified ScrumMaster
My status

Twitter

Flickr

www.flickr.com
This is a Flickr badge showing public photos and videos from Laurent Kempé. Make your own badge here.

Month List

Page List