Global objects Node.js are available in all modules and are global in nature. You don't have to include these objects in your application; you can use them directly instead. These objects are modules, functions, strings, objects and so on. In reality, some of these objects are not in the global scope but in the scope of the module.
A list of Node.js global objects are given below:
This is a string. It specifies the directory name which the code currently contains.File: global-example1.js
Open the command prompt Node.js and run the code below:node global-example1.js
It specifies the code being executed as the filename. This is the absolute path of this code file which is resolved. The value within a module is the path to the file for that moduleFile: global-example2.js
Open the command prompt Node.js and run the code below:node global-example2.js