In nodejs there is the path module and the resolve method of that module than can be used to resolve a relative path to an absolute path. A relative path can be a string representation of the current working directory, or to some other relative path to a resource. It is generally a god idea to think more so in terms of absolute paths to things rather than relative ones to help eliminate confusion.
So say I use a string of period to refer to the current working directory. Doing so might not be the best way of doing so in a node project, but for the sake of this section lets just go with that for a moment. If I want to convert the string of a period to an absolute path to the current working directory then I can use the path resolve method to do so.
2 - The __dirname value, the process.cwd method, the current module directory, and the current working directory.
Although the path resolve method is the tool that I go for to make sure I am always working with an absolute path, it is of course just part of the toolbox. In just about all use case examples I could use the path resolve method with the string of a period to refer to the current working directory, but I tend to prefer using the process cwd method to do so in place of that. In addition if I want to refer to the absolute path of the module that is called rather than the current working directory the use of the path resolve method with a period will not cut it, I will want to use the __dirname value.
The process cwd method should always refer to the current working directory, and the value of __dirname should always refer to the location of the module. In addition there is the __filename value that is the full file name of the current module, that can be passed to a method like the path dirname method to get the location of the current module.
So the path resolve method is the standard go to method for making sure that a string value of a path resolves to an absolute path. There is much more to writ about when it comes to things that have to do with paths and nodejs though. For example there is looping backward one folder at a time from the current working directory looking for something to find out of the current working directory is a git folder or not. That of course is a matter for another post though.