__dirname
: This gives us the path from the OS to the folder in which you used it. (important is folder here because we used this command in some file that reside inside that folder)
FOR EXAMPLE: C:\Users\Lenovo\Desktop\Fun\routes\shop.js
this is the path in which we used __dirname
then we will going to get path upto
C:\Users\Lenovo\Desktop\Fun\routes\
__filename
: This command when used gives the full path from OS to the file in which we used it.
So for above example we will get C:\Users\Lenovo\Desktop\Fun\routes\shop.js
Now we know that node js ships with it a core module that is path
module.