diff --git a/lib/module.js b/lib/module.js index 74db325dabe276..526b1fa313f2cd 100644 --- a/lib/module.js +++ b/lib/module.js @@ -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. @@ -216,7 +217,7 @@ Module._nodeModulePaths = function(from) { paths.push(dir); } - return paths; + return [from].concat(paths); }; @@ -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]; }