Skip to content
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

module: the node_modules paths always should be placed below the current directory #5690

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ Module._nodeModulePaths = function(from) {
// guarantee that 'from' is absolute.
from = path.resolve(from);


// note: this approach *only* works when the path is guaranteed
// to be absolute. Doing a fully-edge-case-correct path.split
// that works on both Windows and Posix is non-trivial.
Expand All @@ -216,7 +217,7 @@ Module._nodeModulePaths = function(from) {
paths.push(dir);
}

return paths;
return [from].concat(paths);
};


Expand Down Expand Up @@ -250,7 +251,7 @@ Module._resolveLookupPaths = function(request, parent) {
if (!parent || !parent.id || !parent.filename) {
// make require('./path/to/foo') work - normally the path is taken
// from realpath(__filename) but with eval there is no filename
var mainPaths = ['.'].concat(modulePaths);
var mainPaths = modulePaths;
mainPaths = Module._nodeModulePaths('.').concat(mainPaths);
return [request, mainPaths];
}
Expand Down