I'm trying to write a debugging framework for node.js and am having a hard time figuring out how to get the full path to a core module file like fs.js
.
I've heard it's in the /lib
folder of the node installation, but I'd need to get this from the code in a consistent way for a variety of install situations (including windows).
I've tried taking a look at the process
and process.env
values for something like a node install path but can't see anything that immediately pops out at me.
To find where the installed node executable is located you can look at the process.execPath which gives the absolute path to Node executable.
To find where a certain module is located you can use require.resolve(module);
However I think the global modules are not directly accessible from the filesystem as other regular modules since they seem to be cached somewhere within the executable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With