0

It’s become clear to me that I am a below average programmer and there is no such thing as a working example of an express/socket.io server on the internet. Why am I getting this error when I try to load the page?

GET http://localhost:3700/socket.io/socket.io.js 404 (Not Found) 

I executed the following command inside of my working directory to install express and socket.io

Npm install 

My package.json file looks like this

{ "name": "RealTimeWebChat", "version": "0.0.0", "description": "Real time web chat", "dependencies": { "socket.io": "latest", "express": "latest", "jade": "latest" }, "author": "developer" } 

This created a “node_modules” directory, inside of which is a “socket.io” directory.

So why can’t my application find the socket.io.js file?

Other relevant information, I’m working off this tutorial. I’m following it word for word.
I have a .jade file that looks like this.

!!! html head title= "Real time web chat" script(src='/chat.js') script(src='/socket.io/socket.io.js') body #content(style='width: 500px; height: 300px; margin: 0 0 20px 0; border: solid 1px #999; overflow-y: scroll;') .controls input.field(style='width:350px;') input.send(type='button', value='send') 

Admittedly, I have no idea what jade is, but I'm just trying to get a simple example up and running. I learn best as I do. Final project is due on Sunday! Help I need a server!

1
  • Please also post your server-side code, it looks like you're not binding Socket.io to the connection. Commented Dec 6, 2013 at 14:11

1 Answer 1

0

I've got an end-to-end working example of Express and Socket.io on GitHub at https://github.com/hectorcorrea/intro-to-nodejs

Try this:

git clone https://github.com/hectorcorrea/intro-to-nodejs.git cd intro-to-nodejs npm install npm install socket.io node socketioDemo 

Then open two browser windows and browse to http://localhost:3000 and you should be able to exchange messages between the two.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your response. I think you are forgetting that I'm a below average programmer. Can I do this without the github portion? For example, can I place "intro-to-nodejs-master" inside of a folder called "intro-to-nodejs", then run the npm install commands? Or do I need to run the npm install command inside of the master directory?
Ok wait, I removed "master" from the directory, used cd to get inside the directory and performed npm install. On the right track...
Wow Hector. Your demo is the only one I've gotten to work after trying virtually every demo on the web. Yours worked right away. Time to dissect and try learn. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.