Simple Chat Server Using Nodejs & Socket.io

Satheesh Kumar
2 min readOct 31, 2017

--

In this tutorial we assume that you have nodejs latest version installed on your system.

1. Install Dependencies:

Move to the folder where you want to create the application and open terminal /command prompt from that folder. We need express, socket.io & ejs modules to run the server. We can install them manually. To start an new nodejs project run the following command

npm init

This will generate the package.json file in the current folder.

Install node_modules need to run the server by

npm install --save express ejs socket.io

After installing the node_modules you package.json will look like,

2. Create start script (app.js)

App.js is the main file from which the server starts its execution, your start file must look like,

3. Create a Index view

Create a folder named views, inside which create a file called index.ejs and add contents to it.

After adding these start the server using the command

npm start

Open http://127.0.0.1:8000 and enjoy chatting.

The whole server files can be downloaded or cloned from GitHub.

https://github.com/satheesh1997/Socket.io-Chat-Server

Server Image
Application opened on client

--

--