Node.js | process.execPath Property

The process.execArgv 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.execArgv

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:



filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

C:\Program Files\nodejs\node.exe

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);
  
// Seperated directories and file
console.log(execpath.split(path.sep));

chevron_right


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

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.