Defining paths for loaded modules in Node.js

In Node.js, is there a way to determine where the module from was loaded on the file system?

I am doing NOT what directory context Node.js is running in - which you can define with process.cwd(). I want to know something specific about which module is in memory.

For example, 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 the module is located on the file system os. Is there a way to do something like this in Node.js?


NOTE: I tried to ask this question when I asked my previous question , but I formulated it poorly and ended up receiving an answer to another question.
+3
source
2

require.resolve('module_name')

+6

, require.resolve(...), , .

0

All Articles