Node.js process.execPath Property
Last Updated :
28 Jul, 2022
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
const process = require( 'process' );
console.log(process.execPath);
|
Output:
C:\Program Files\nodejs\node.exe
Example 2:
javascript
const process = require( 'process' );
const path = require( 'path' );
var execpath = process.execPath
console.log(execpath);
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...