Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the original full command line used to launch NodeJS program?

I can use process.argv to get an array of arguments passed to the NodeJS program, but is there a way to get the full exact command line string entered on the shell that the NodeJS program was launched with? If not the exact string, is there any close equivalent that can be determined?

like image 664
user779159 Avatar asked Sep 06 '25 11:09

user779159


1 Answers

process.argv is the correct way. As a start, you can do:

console.log(process.argv.join(" "))

Then you can change paths to relative paths if you wish.

like image 111
RaphaMex Avatar answered Sep 09 '25 02:09

RaphaMex