How to connect via reqiure a script in nodejs?

I recently started to understand NodeJS, and generally all turns out, but I can't figure out how to connect to the main file with your other scripts.
Let me explain with an example.
I have two script index.js and test.js and I want test.js to connect to the index.
In the code I do var test = require('./test');. It's easy, there's no question. But how to make sure that they work?
Each file is executed (successfully) code.
var test = require('./test');
var id = 2+2;

ID successfully obtained.

In the file test runs successfully is not associated with the first file identification (ID I put hands):
var id = 4;
var info1 = id+15;
var info2 = id+10;

Actually a question - how to attach the file test.js to run in index.js took id in the first file output console.log(info1); and console.log(info2); that is the result of the first file was:

Searches over the network gave some results, but the examples and explanations there is quite abstract, I alas was not able to relate with your example.
June 10th 19 at 15:13
1 answer
June 10th 19 at 15:15
If you want to shoot data to the module, you need to make a function inside the module and transfer data through a function parameter.
function init(id) {
 // code
module.exports = { init };

var id = 2+2;
var test = require('./test');

But in General, if you want to work with some data and all the logic to render in the module, it is better to make a class and instantiate it in index.js

Find more questions by tags Node.js