Node.js hello world on Windows

1] Download node.exe
Location: https://github.com/tjanczuk/node/downloads
Default installation: C:\Program Files\nodejs

2] Write helloworld.js javascript file:

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

3] Run
(In dos): Run node.exe helloworld.js

Console should be saying: ‘Server running at http://127.0.0.1:8124/’

4] Call from browser
http://127.0.0.1:8124/

image
Voila an other hello world!

More info: http://www.nodebeginner.org/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s