Socket.IO/Node.JS execution

I'm new to both Node.JS and Socket.IO, so I decided to pick up a simple chat client as my first project. To my knowledge, it structured correctly, but I'm being thrown an object expected error whenever I try to run index.js. Anyone know what's up? (if it helps, I'm running on Windows 8.1)



<!doctype html> <html> <head> <title>TNjs Chat</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font: 13px Helvetica, Arial; } form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; } form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; } form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; } #messages { list-style-type: none; margin: 0; padding: 0; } #messages li { padding: 5px 10px; } #messages li:nth-child(odd) { background: #eee; } </style> </head> <body> <ul id="messages"></ul> <form action=""> <input id="m" autocomplete="off" /><button>Send</button> </form> <script src=""></script> <script src=""></script> <script> var socket = io(); $('form').submit(function(){ socket.emit('chat message', $('#m').val()); $('#m').val(''); return false; }); socket.on('chat message', function(msg){ $('#messages').append($('<li>').text(msg)); }); </script> </body> </html>


var app = require('express')(); var http = require('http').Server(app); var io = require('')(http); app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); io.on('connection', function(socket){ socket.on('chat message', function(msg){ io.emit('chat message', msg); }); }); http.listen(3000, function(){ console.log('listening on *:3000'); });


{ "name": "TNjsChat Client", "version": "0.0.1", "description": "A browser based chat system using Node.JS and, by Touka", "dependencies": { "express": "4.10.2", "": "1.2.0" } }

-------------Problems Reply------------

You need to run node, not just let Microsoft IE run the js file which is what your screenshot seems to show.

Make sure node.exe is in the path somewhere and then run "node index.js" from the index.js directory and make sure all modules you need (like Express) are installed properly and available from the index.js directory.

Category:javascript Views:3 Time:2017-04-23

Related post

  • LearnBoost's Socket.IO-Node why onClientMessage not work 2010-06-06

    I tried to put the module "LearnBoost's Socket.IO-Node", all works, except event 'onClientMessage' Tell, in what there can be a problem, thanks! ...sorry for my english io.listen(server, { onClientConnect: function(client){ client.send(json({ buffer:

  • Using a Flash socket with Node.js 2010-09-03

    I've been using gimite / web-socket-js to implement a WebSocket past simply Chrome and development builds of Safari. I want to move away from the Ruby server and onto Node.js. Suddenly it doesn't work in anything but Chrome. I suspect that this has t

  • Sending data only to chosen users using 2011-02-09

    Is it possible to send data using just to chosen group of users? For example, how could I implement chat with different rooms? I dont want .broadcast() to send data to all logged in users. --------------Solutions------------- Normally

  • Cannot find module 'Socket.IO-node' when trying to run node.js boilerplate project 2011-07-06

    I'm getting an error when I try to run a project created with the node.js boilerplate project I've installed using NPM with this command: npm install The error I'm getting is: node.js:189 throw e; // process.nextTick error, or 'er

  • How to uniquely identify a socket with Node.js 2011-07-24

    TLDR; How to identify sockets in event based programming model. I am just starting up with node.js , in the past i have done most of my coding part in C++ and PHP sockets() so node.js is something extremely new to me. In c++ to identify a socket we c

  • multiuser paint app with html5 canvas node.js 2012-01-16

    I am doing kind of multi-user application with html5 canvas,, node.js Over now I am using broadcast to send canvas state to others, but I can see that there is sometimes kind of race: Changing stroke properties(like color or lineWidth) in o

  • website using WebG, HTML5, MongoDB, Three.js, Socket.IO, Node JS requires chrome or firefox, why? 2013-06-27

    website website states using the following technologies: WebG, HTML5, MongoDB, Three.js, Socket.IO, Node JS requires chrome or firefox only. It is not functioning using IE9. Ideas for a workaround. --------------Solutions----

  • Socket.IO / Node.JS / Rails 3 / IE 2010-09-29

    This is a bit complicated but here goes. I have a Rails app that has a small JS widget that gets updated on some backend processing stuff. The Rails app queues up a job in Redis (via Kthxbye) which gets processed and then once completed, fires off a

  • Socket.IO / node.js problem: unintended disconnects 2011-02-19

    I see this sort of thing in my node log fairly frequently: 19 Feb 13:50:20 - Initializing client with transport "flashsocket" 19 Feb 13:50:20 - Client 5846663371194154 connected 19 Feb 13:50:20 - Client 5846663371194154 disconnected It seems to happe

  • Node.js error in IE7 - Access Denied 2011-03-02

    I am using to connect to my node server using the following script: $socket = new io.Socket(null,{port:8086,rememberTransport:false}); $socket.connect(); If works fine in IE8/9, Chrome, Safari & FF. When I try it in IE7, a connection is

  • socket with node js example 2011-03-30

    Hi all i have problem.... Client side code <html> <body onload="fun()"> <script src="C:\cygwin\usr\local\lib\node\.npm\\package\support\\"></script> <script> function fun() { ale

  • Rails and (node.js) 2011-04-05

    I intend to use a Rails app to serve real-time data processed by a node.js server and In the website, it says that: If you won't leverage Node.JS to serve your files, make sure to set the global WEB_SOCKET_SWF_LOCATION to the loc

  • Memory Leak with + node.js 2011-06-24

    I appear to have a memory leak with my node application. I built it quickly, and my JavaScript isn't too strong, so this might be easy. I've done some heap dumps on it, and it's the String 'object'? leaking memory, at the rate of about 1MB every 5 mi

  • Formatting messages to send to node.js server from python client 2011-07-14

    I'm trying to get a python client talking to a node.js server using 0.7, by sending a custom event to the server. Based on the reference I have found here:, and the following websocket

  • zombie.js and (node.js) 2011-08-16

    I would like to test my node.js/ application using the zombie.js headless browser. Unfortunately when the zombie.js app connects to my app it reports a load of connection/disconnection events. Eg. Zombie: Firing timeout 234, delay: 1000 Zomb

  • Node.js + + node-amqp and queue binginds when "re" connecting thru 2011-09-29

    I have one scenario which is very close to this sample: One main screen: this screen (client side) will connect to the server thru server:9090/scope (io.connect("http://server:9090/scope)) and will send one event "userBindOk" (socket.emit("

  • Can't connect and getting a "unhandled url" error with MAMP + (node.js) 2011-10-16

    I'm developing an application using CodeIgniter on a MAMP server (for development, live it'll be on LAMP). I'm trying to add the real-time functionality of for a chat server, but I'm having some issues. I have and MAMP up and runn

  • javascript - Server not handle event ( 2012-01-21

    I've just started with Node.js/ and want to build an sample app in which: When connected, both server and client print 'connected!'. Everytime client submit a message, server print content and respond back to client. Here is my code: NodeJS

  • Realtime application - alternative for (node.js) 2012-03-21

    I use node.js. I am looking for an alternative for I need to send a private message to the user. What is the alternative for the SOCKET.IO? --------------Solutions------------- You haven't really explained why you're looking for Socket.IO.

  • How to send message from one node application to other node application 2013-04-29

    In my node application I need to send message to other node application using Because depending upon the first application results I need to do some tasks in second application. How can I do this? var express=require('express'); var http=r

  • how to keep alive a socket in node.js in appfog 2013-06-16

    I have a long running socket which I need to keep alive even when the system is idle. For that I have tried everything from reduced long polling duration to a server and client ping pong messages but, nothing seems to work as the socket gets disconne

  • Cross-browser BSD-style sockets or Node.js streams 2013-06-27

    I'm in the process of implementing a streaming protocol in JavaScript. The protocol is defined in terms of byte streams, not messages. I'd like to be able to talk to browsers using this protocol. I've used in the past for easy cross-browser

  • How to listen to a random tcp socket in node.js 2010-08-18

    I know I can create a tcp server like that in node.js var dataServer = net.createServer(function (stream) { }); dataServer.on("listening", function() { // this data server listen to a random port // but how can I get the number of port console.log(da

  • on local network? 2011-09-19

    I have two machines on the same network say at and = server/dev pc = client/browser pc So on the server/dev pc I have a server running on port 82 On the client server I'm using chrome as

Copyright (C), All Rights Reserved.

processed in 0.149 (s). 11 q(s)