node.js

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

Current Version: v0.9.11

Fork me on GitHub

Node.js in the Industry

  • Node gives Azure users the first end-to-end JavaScript experience for the development of a whole new class of real-time applications.
    Claudio Caldato
    Principal Program Manager, Microsoft Open Technologies, Inc.

  • Node’s evented I/O model freed us from worrying about locking and concurrency issues that are common with multithreaded async I/O.
    Subbu Allamarju
    Principal Member, Technical Staff

  • On the server side, our entire mobile software stack is completely built in Node. One reason was scale. The second is Node showed us huge performance gains.
    Kiran Prasad
    Director of Engineering, Mobile

  • Node.js is the execution core of Manhattan. Allowing developers to build one code base using one language – that is the nirvana for developers.
    Renaud Waldura
    Sr. Product Manger, Cocktail

An example: Webserver

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, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

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 http://127.0.0.1:1337/

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, '127.0.0.1');