Reputation: 9592
Both "return the current working directory of the process".
It seems you can override the value of process.env.PWD
but it will not change the returning value of process.cwd()
.
Upvotes: 21
Views: 12271
Reputation: 161487
PWD
is the current working directory when the process is started, but it is constant. process.cwd()
is asking the underlying system for the process's current directory, which can be changed with process.chdir()
. PWD
is also a POSIX environmental variable, which means it won't work on Windows. process.cwd()
on the other hand, will.
Upvotes: 46