app-module-path-node icon indicating copy to clipboard operation
app-module-path-node copied to clipboard

specify how this works in readme.md

Open ORESoftware opened this issue 7 years ago • 3 comments

Hi all

Checking this library out - trying to figure out how it works - it looks like it doesn't use NODE_PATH (that wouldn't really be possible given the nature of this), so how does it work?

I probably won't use it unless I know how it works, will try to poke around some more to figure it out

ORESoftware avatar Dec 04 '16 19:12 ORESoftware

This module works by monkey-patching the internal require('module').Module._nodeModulePaths method to prepend additional directories: https://github.com/patrick-steele-idem/app-module-path-node/blob/97fc60947bcca6e194f549d0d374ef34a5eb49df/lib/index.js#L7-L17

You may want to consider using the more recent require-self-ref module as an alternative. Both app-module-path and require-self-ref work, but I find require-self-ref to be cleaner. require-self-ref monkey patches the internal require('module').Module. _resolveFilename method.

I don't have time to update the README at the moment, but hopefully that helps clarify.

patrick-steele-idem avatar Dec 04 '16 21:12 patrick-steele-idem

thanks that helps! you probably could just copy and paste this answer to the top of the readme

ORESoftware avatar Dec 04 '16 21:12 ORESoftware

it's up to you if you want to merge it

https://github.com/patrick-steele-idem/app-module-path-node/pull/24

thanks

ORESoftware avatar Dec 04 '16 21:12 ORESoftware