bert

Just another Wordpress.com weblog

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/

October 19, 2011 Posted by | Uncategorized | Leave a Comment

   

Follow

Get every new post delivered to your Inbox.