They are related to each other, but not the same thing.
process.env.PWD is the working directory when the process starts. This remains unchanged for the entire process.
process.cwd() is the current working directory. It reflects the changes made using process.chdir() .
You can manipulate PWD , but it would be pointless to do this, this variable is not used by anything, it is just for convenience.
To calculate the paths, you probably want to do this as follows:
var path = require('path'); path.resolve(__dirname, 'app/server')
Where __dirname reflects the directory in which the source file is located, this code is listed in the residence. It is wrong to expect cwd() be anywhere. If your server process is running from anywhere except the main source directory, all your paths will be invalid using cwd() .
source share