Skip to content

specify how this works in readme.md #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ORESoftware opened this issue Dec 4, 2016 · 3 comments
Open

specify how this works in readme.md #23

ORESoftware opened this issue Dec 4, 2016 · 3 comments

Comments

@ORESoftware
Copy link

ORESoftware commented Dec 4, 2016

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

@patrick-steele-idem
Copy link
Owner

This module works by monkey-patching the internal require('module').Module._nodeModulePaths method to prepend additional directories:

Module._nodeModulePaths = function(from) {
var paths = old_nodeModulePaths.call(this, from);
// Only include the app module path for top-level modules
// that were not installed:
if (from.indexOf('node_modules') === -1) {
paths = paths.concat(appModulePaths);
}
return paths;
};

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.

@ORESoftware
Copy link
Author

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

@ORESoftware
Copy link
Author

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

#24

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants