Now, you will think how you are able to use exports, require, module, __filename and __dirname in your node js file.

Answer is your file is wrapped in function. So, assume you are writing code in function and your code is able to use all function arguments. This is what actually happens.

Nodejs is achieving following things by doing this:
As you understood your code is wrapped in function so top level variables defined with var, let and const scoped to that module and not become the global object.

__dirname: It will give you directory name of the current module.
Suppose your file is at: /home/galitein/project/example.js
You are writing console.log(__dirname) in example.js then output will be: /home/galitein/project

__filename: It will give you file name of the current module.
Suppose your file is at: /home/galitein/project/example.js
You are writing console.log(__filename) in example.js then output will be: /home/galitein/project/example.js