Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9179751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:52:44+00:00 2026-06-17T17:52:44+00:00

I’m making a little Node app using socket.io 0.9.13 using Express 3.0.6. I can’t

  • 0

I’m making a little Node app using socket.io 0.9.13 using Express 3.0.6. I can’t seem to anything even starting to run because it says socket.io has no method listen(). Here’s my code (compiled coffeescript, so it’s a bit ugly):

(function() {
  var app, express, io, port, usernames;

  express = require('express');

  app = express();

  io = require('socket.io'.listen(3000));

  port = 3000;

  app.listen(port);

  console.log("Listening on port " + port);

  console.log('CNTRL-C to quit.');

  app.engine('hamlc', require('haml-coffee'.__express));

  app.get('/', function(request, response) {
    return response.render('index.hamlc');
  });

  usernames = {};

  io.sockets.on('connection', function(socket) {
    socket.on('send-chat', function(msg) {
      return io.sockets.emit('update-chat', socket.username, msg);
    });
    socket.on('add-user', function(username) {
      socket.username = username;
      usernames[username] = username;
      socket.emit('update-chat', 'SERVER', "You have connected as " + username + ".");
      socket.broadcast.emit('update-users', 'SERVER', "" + username + " has joined the chat.");
      return io.sockets.emit('update-users', usernames);
    });
    return socket.on('disconnect', function() {
      delete usernames[socket.username];
      io.sockets.emit('update-users', usernames);
      return socket.broadcast.emit('update-chat', 'SERVER', "" + socket.username + " has disconnected from chat");
    });
  });

}).call(this);

Which raises the following error:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
TypeError: Object socket.io has no method 'listen'
    at Object.<anonymous> (/Users/chris/src/web/kouv/app.js:8:28)
    at Object.<anonymous> (/Users/chris/src/web/kouv/app.js:44:4)
    at Module._compile (module.js:432:26)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Array.0 (module.js:470:10)
    at EventEmitter._tickCallback (node.js:192:40)

Answer appreciated greatly. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:52:45+00:00Added an answer on June 17, 2026 at 5:52 pm

    Try this:

    var express = require('express'),
        http = require('http');
    
    var app = express();
    var server = http.createServer(app);
    
    var io = require('socket.io').listen(server);
    server.listen(3000);
    

    Socket.io essentially hijacks the http object when it runs; express 3.xx no longer runs off the http.server though, so it’s necessary to create your own instance of it for socket.io to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I am writing an app for my school newspaper, which is run completely online
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.