Of course, you first need to download and install Node.js: https://nodejs.org/en/download/

Then, you have to create a folder for your project and go there.
Open the console terminal, and write this command to create package.json

npm init -y

Install “socket.io” and “express” to a local “node_modules” folder.
Then open your console terminal again and enter this command :

npm install — save socket.io express

It’s now time for you to write a simpler server script and a client script. Use what you are familiar with. If you have no preferences, then I guess I could advise you to use https://code.visualstudio.com/

Create two folders in your project: “server” and “client”.

Then, create the “index.html” file in the “server” folder. Here is what it should look like :

<!DOCTYPE html>
<html lang="en">

<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta http-equiv="X-UA-Compatible" content="ie=edge">
   <title>Multiplayer Snake</title>
</head>

<body>
   <h1>Hello, World</h1>
</body>

</html>

Also create a “client.js” file in the “client” folder

And then, create the “app.js” file in the “server” folder. Here is what it should look like :

var express = require("express");
var app = express();
var server = require("http").Server(app);

app.get("/", function(req, res)
{
   res.sendFile(__dirname + "/client/index.html");
});
app.use("/client", express.static(__dirname + "/client"));

var port = 8080;
server.listen(port);
console.log("Server started. Port = " + port);

Want to test if you’re okay so far ? Run this script from the console terminal using the following command:

node app.js

It should display: “Server started. Port = 8080”.
Then, write the address localhost:8080 in your browser:
You will see “Hello, World” displaying on the webpage.

Okay, so that’s good. Now, let’s find “cnd socket.io” url in the Internet. To do that, add this code to the “index.html” file:

<!DOCTYPE html>
<html lang="en">

<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta http-equiv="X-UA-Compatible" content="ie=edge">
   <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
   <title>Multiplayer Snake</title>
</head>

<body>
   <h1>Hello, World</h1>
   <script>
       var socket = io();
   </script>
</body>

</html>

Then create a socket callback in your app.js file

var express = require("express");
var app = express();
var server = require("http").Server(app);

app.get("/", function(req, res)
{
   res.sendFile(__dirname + "/client/index.html");
});
app.use("/client", express.static(__dirname + "/client"));

var port = 8080;
server.listen(port);
console.log("Server started. Port = " + port);

var io = require("socket.io")(server, {});

io.sockets.on("connection", function(socket)
{
   console.log("socket connection");
});

Now repeat the last verification you did :

Run the script:

node app.js

Enter the following “localhost:8080” in your browser: localhost:8080
You will see the message “socket connection” displaying in the console.

CONGRATS.

If something went wrong, you can also watch this nice tutorial : Setup & Sending Files. Node.js Tutorial Guide