How to use socket io connect?

var io = require('socket.io');
var socket = io.connect('http://localhost');

Throws TypeError: Object #<Object> has no method 'connect'

What am I doing wrong?

EDIT: More info: using node.js. Installed socket.io with npm install socket.io

Using node test.js to run.

var socket = io.connect('your host');

This is a part of your javascript code declared in your js tag in index.html file. Mean this is code runed on client machine.

see carefully on http://socket.io/#how-to-use