Node.js __filename object Last Updated : 06 Apr, 2021 Comments Improve Suggest changes Like Article Like Report The __filename in the Node.js returns the filename of the code which is executed. It gives the absolute path of the code file. The following approach covers how to implement __filename in the NodeJS project. Syntax: console.log(__filename)Prerequisites: Basic knowledge of Node.jsNode.js installed (version 12+)NPM installed (version 6+)Return Value: It returns the absolute filename of the current module. Example 1: Create a JavaScript file index.js and write down the following code: index.js // Node.js code to demonstrate the absolute // file name of the current Module. console.log("Filename of the current file is: ", __filename); Run the index.js file using the following command: node index.js Output: Filename of the current file is: C:\Users\Pallavi\Desktop\node_func\app.jsExample 2: index.js // Node.js code to demonstrate the absolute // file name of the current Module console.log(__filename); // To show to parts of file using filename. const parts = __filename.split(/[\\/]/); console.log( "This the all the parts " + "present in file :",parts); Output: C:\Users\Pallavi\Desktop\node_func\app.js This the all the parts present in file : [ 'C:', 'Users', 'Pallavi', 'Desktop', 'node_func', 'app.js' ] Reference: https://nodejs.org/api/globals.html#globals_filename Comment More infoAdvertise with us Next Article Node.js __filename object _sh_pallavi Follow Improve Article Tags : JavaScript Web Technologies Node.js Node.js-Basics Similar Reads Node.js __dirname Variable The __dirname string gives the directory path of the current module, this is also similar to that of path.dirname() of the filename. Return Value : It returns the directory path of the current module. Example 1: Let's create a file main.js main.js import path from 'path'; const __dirname = path.reso 1 min read Node.js File System The fs (File System) module in Node.js provides an API for interacting with the file system. It allows you to perform operations such as reading, writing, updating, and deleting files and directories, which are essential for server-side applications and scripts.Table of ContentNode.js file systemKey 9 min read NodeJS Global Objects In NodeJS global objects are the objects that are accessible in the application from anywhere without explicitly using the import or require. In browser-based JavaScript, the window object is the global scope, meaning it holds all global variables and functions. In NodeJS, instead of the window obje 6 min read Node.js process.report.filename Property The process.report.filename is an inbuilt application programming interface of class Process within process module which is used to get or set the file name where the report is written. Syntax: const process.report.filename Parameters: This api takes no argument as a parameter. Return Value: This ap 1 min read Node.js process Object A process object is a global object, so it can be accessed from anywhere. As it is a predefined library, so we don't have to download it to our system globally. Prerequisites: Basic knowledge of  NodeNode.js installed (version 12+)NPM installed (version 6+)Requiring Module: You can include the modul 2 min read Like