Working with paths in node.js is something that comes up all the time. A nice way to help with joining paths together, and help with problems that have to do with the differences of how paths are handled in windows and linux systems. For this there is no need to bother with an npm package of any kind the node.js built in path module can help with a great deal of these kinds of tasks.
This is a task that I use the path module for all the time.
Another task that is quickly solved with the path module is getting the base name of a path. This is helpful for getting a filename from the end of a path.
Opposite of basename is path.dirname.
I often end up in situations in which I have many different path parts and I want to piece them together into a single path in a way in which it will always come together in a single valid path. The join method serves me well with this.
An absolute path is a full path all the way back to root. On a posix system an absoliute path is something like this
On a windows system it would be something like this
This differs from a relative path like this
As such it is nice to have a way to find out if a path is absolute or not, so there is a method for that called path.isAbsolute.
I recently ran into a situation in which I need to find out if a path is a sub dir of another path in order to exclude it if it is. Path.relative comes in handy with this.