If you’re running Express 4, it appears to me like you’re missing the lines of code:
var app = express(); var server = app.listen(3000);
That will start your web server and set it to port 3000. See the bone simple Express 4 app here: http://expressjs.com/4x/api.html
And, then to start up socket.io, you would add:
var io = require('socket.io').listen(server);
And, there is no need for this line:
var http = require('http');
- How to remove debugging from an Express app?
- How to share sessions with Socket.IO 1.x and Express 4.x?
- socket.io and session?
- “connect EMFILE” error in Node.js
- Node.js EMFILE error with increasing traffic
- Express-js can’t GET my static files, why?
- How to get all registered routes in Express?
- Proper way to set response status and JSON content in a REST API made with nodejs and express
- What are “res” and “req” parameters in Express functions?
- create a trusted self-signed SSL cert for localhost (for use with Express/Node)
- Creating a expressjs middleware that accepts parameters
- Using app.configure in express
- Adding timestamps to all console messages
- Node.js – logging / Use morgan and winston
- Node/Express file upload
- Difference Between app.use() and router.use() in Express
- Using PassportJS, how does one pass additional form fields to the local authentication strategy?
- Node.js + Express: Routes vs controller
- Why should I use Restify?
- Uploading images using Node.js, Express, and Mongoose
- Node.js get image from web and encode with base64
- Using socket.io in Express 4 and express-generator’s /bin/www
- Difference between Node js and express js [closed]
- How to confirm email address using express/node?
- Express.js routing: optional splat param?
- How to check in node if module exists and if exists to load?
- Express Passport (node.js) error handling
- How to know if a request is http or https in node.js
- How to change default layout in express using handlebars?
- What’s difference with express-session and cookie-session?
- Node.js, PostgreSQL error: no pg_hba.conf entry for host
- reCAPTCHA – error-codes: ‘missing-input-response’, ‘missing-input-secret’ when verifying user’s response (missing details on POST)
- POST request not allowed – 405 Not Allowed – nginx, even with headers included
- How to force SSL / https in Express.js
- How can I get Express.js to 404 only on missing routes?
- Add intentional latency in express
- Node.js with Express – throw Error vs next(error)
- Difference between res.setHeader and res.header in node.js
- nodemon + express, listen port =?
- Node.js with Express: how to redirect a POST request
- Node.js: socket.io close client connection
- nodejs send html file to client
- Streaming file from S3 with Express including information on length and filetype
- What is the difference between ‘session’ and ‘cookieSession’ middleware in Connect/Express?
- ExpressJs is return error `ERR_MODULE_NOT_FOUND` if I import the file without `js` extension
- Can not get CSS file
- Node.js + Express + Handlebars.js + partial views
- An import path cannot end with ‘.ts’ – NodeJS and Visual Code
- Logging stdout and stderr of Node
- Multiple View paths on Node.js + Express