Article 6HS9B __dirname syntax

__dirname syntax

by
barry_the_tool
from LinuxQuestions.org on (#6HS9B)
Hello
I have the following line in my code to point to a file

myFile: `${process.cwd()}/${filePath}`, - this is used along with a relative path specified in another file which should reference the file I need

As i am using cwd, the path is often incorrect, it only works when i am in a sepcific directory. I need to change the above so that I can reference the file from any directory - but I cant use an absolute path.

__dirname has been suggested as a solution, but I cant figure out the syntax needed.

Can someone please help? Apologies if the wording above isn't quite right, I hope its explained enough to make sense to whoever reads this!
Thanks
Bazza
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments