Tijl Van den Brugghen
Tijl Van den Brugghen

Reputation: 141

Node.JS know where program is launched from

i'm asking myself if it is possible to see where the user is launching the program from ?
Example : script is in /home/user1/test.js, and the user is inside /home/user1/a-dir/, when he enters
$ node ../test.js
Is it possible to get where the user launched the program from ? (In this case, /home/user1/a-dir/ )

Thanks.

Upvotes: 0

Views: 119

Answers (1)

clns
clns

Reputation: 2304

You can get the current directory of the process with process.cwd().

Upvotes: 1

Related Questions