Computer >> Computer tutorials >  >> Programming >> Javascript

process.argv0() Method in Node.js


The process.argv0() method is used for storing the read-only copy of the original value for argv[0] that is passed when the node.js application is started.

Syntax

process.argv0()

Parameters

Since it returns only the read-only copy for stored value of argv[0]. It does not need any inputs from the user.

Example

Create a file with name – argv0.js and copy the below code snippet. After creating file, use the following command to run this code as shown in the example below −

node argv0.js

argv0.js

// Node.js program to demonstrate the use of process.argv0

// Importing the process module
const process = require('process');

// Printing argv0 value for the process
console.log(process.argv0);

Output

C:\home\node>> node argv0.js
node

Example

Let's take a look at one more example.

// Node.js program to demonstrate the use of process.argv0

// Importing the process module
const process = require('process');

// Printing property value for process.argv0
console.log(process.argv[0]);

Output

C:\home\node>> node argv0.js
/usr/bin/node