0

From the socket.io chat example.
What does it mean in the index.js:

var io = require('../..')(server);

What does '../..' means? I looked up the some information and some say that '../' means the index.js in the parent folder, is that correct?

I noticed that the index.js is missing require('socket.io')(server);

index.js:
var express = require('express');
var app = express();
var path = require('path');
var server = require('http').createServer(app);
var io = require('../..')(server);
var port = process.env.PORT || 3000;

so maybe ../.. require socket.io for us too?

Found same question on SO:

Here's the link

1 Answers1

0

Basically ../ means moving into the parent directory of current directory.So the following line means ../.. will start searching the parent of parent directory will try to access server module form the same.

var io = require('../..')(server);

Suppose currently you are in Project/fol1/fol2 folder where index.js file is located,so if you want to require a module or file in project folder then you will have to move to the path first before accessing module "../.." this will do the same.

Please refer following link question answered by Adam you will get clear idea. node.js filesystem

Neha Tawar
  • 687
  • 7
  • 23