Open In App

Node.js process.execPath Property

Last Updated : 25 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The process.execPath property is an inbuilt application programming interface of the process module which is used to get the absolute pathname of the node.js executable which started the node.js process.
Syntax: 
 

process.execPath


Return Value: This property returns a string signifies the absolute path of the node.js executable which started the node.js process.
Below examples illustrate the use of process.execPath property in Node.js:
Example 1: 
 

javascript

// Node.js program to demonstrate the   
// process.execPath property
 
// Include process module
const process = require('process');
 
// Printing process.execPath
console.log(process.execPath);

                    

Output: 
 

C:\Program Files\nodejs\node.exe


Example 2: 
 

javascript

// Node.js program to demonstrate the   
// process.execPath property
 
// Include process module
const process = require('process');
 
// Include path module
const path = require('path');
  
// Printing process.execPath
var execpath = process.execPath
console.log(execpath);
 
// Separated directories and file
console.log(execpath.split(path.sep));

                    

Output: 
 

C:\Program Files\nodejs\node.exe
[ 'C:', 'Program Files', 'nodejs', 'node.exe' ]


Note: The above program will compile and run by using the node filename.js command.
Reference: https://nodejs.org/api/process.html#process_process_execpath
 


Next Article

Similar Reads