In Node.js, is there any way to determine where on the filesystem a module was loaded from?
I do NOT mean, what directory context Node.js is executing in--which you can determine with process.cwd()
. I want to know something specific about whatever module is in memory.
For instance, in Python I can do the following...
>>> import os
>>> os.__file__
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.pyc'
Which shows me where on the filesystem the os
module is from. Is there anyway to do something similar in Node.js?
NOTE: I was trying to ask this question when I asked my previous question, but I phrased it poorly and ended up getting an answer to a different question.