Some paths in the module search do not make sens in some case #11657

laurentj opened this Issue Oct 3, 2013 · 1 comment


None yet
2 participants

laurentj commented Oct 3, 2013

In Module.prototype._getPaths (bootstrap.js, see issue #11339), paths of require.paths are in the list of path where to search the given requested module.

However, when the given requested module id is relative, or when it is an absolute path, it does not make sens to search in the list of require.paths.

for example:


and let's imagine that in a module we do


Then we will have in _paths:

  • /home/me/mymodule because of } else if (fs.isAbsolute(request)) {. This is ok.
  • but also /usr/local/lib/some_modules/home/me/mymodule

This second path should not be there....

Same thing for a relative path:


We expect that the search will be done only relatively with the path of the current module, not with all path in require.paths.

so the list of require.paths should be added in _paths only in the third case, when the id does not begin with a '.', and when it is not an absolute path.


JamesMGreene commented Oct 4, 2013

As usual, I'll reiterate that the idea was to follow Node's module system setup but I don't believe we applied all of the logic branches, thus resulting in the current weirdness.

Here are Node's rules:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment