Path.resolve() in Node.js

Ifeanyi Chima - Jul 20 '22 - - Dev Community

This post will help you understand path.resolve() in NodeJs, which is a very useful module.

BMC

Absolute path
Firstly, you need to understand what an absolute path is, it looks like this

C:\Users\PC_Name\Music\Music

Your system generates this path to locate any file, folder e.t.c
To achieve this open your system terminal on windows Win + R type cmd and click OK

carry out the following steps,

cd music

cd music

Using NodeJs



path.resolve("_dirname", "music", "music")


Enter fullscreen mode Exit fullscreen mode

This will return C:\Users\PC_Name\Music\Music

path.resolve() will always result in an absolute path, which is how to find a file on your computer.

How does path.resolve() work

path.resolve() will process the sequence of path from right-most to left-most, with each subsequent path prepended until an absolute path is constructed.

Buy Me A Coffee

Thank You, please follow me

HTMLĀ GitHub

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player