I notice that Node defines both process.argv
and process.ARGV
(capitalized). The later isn't mentioned in the documentation and is, in every case I've encountered so far, the same object.
Is ARGV
just a historic holdover, or does it have a purpose?
The process. argv() method is used for returning all the command-line arguments that were passed when the Node. js process was being launched. The first element will always contains the same value as process. execPath.
The process module has a property named argv that stores all the command-line arguments passed when you issue the command to start the NodeJS process. The command-line arguments are stored as an array inside the property. As you can see from the log result above, the argv property contains a single array.
process. cwd() returns the current working directory, i.e. the directory from which you invoked the node command. __dirname returns the directory name of the directory containing the JavaScript source code file.
The process. hrtime() method to measure code execution time which returns array which include current high-resolution real time in a [seconds, nanoseconds].
process.ARGV
has been removed entirely since v0.5.10
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With