This post will help you understand path.resolve()
in NodeJs, which is a very useful module.
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")
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.
Thank You, please follow me
Top comments (0)