Closes GH-690 node_modules folders should be highest priority
This commit is contained in:
parent
a48f73d0d3
commit
3599c71dae
@ -212,6 +212,10 @@ the `NODE_PATH` environment variable might have been set to:
|
|||||||
|
|
||||||
/home/micheil/.node_modules:/usr/local/lib/node_modules
|
/home/micheil/.node_modules:/usr/local/lib/node_modules
|
||||||
|
|
||||||
|
Loading from the `require.paths` locations is only performed if the
|
||||||
|
module could not be found using the `node_modules` algorithm above.
|
||||||
|
Global modules are lower priority than bundled dependencies.
|
||||||
|
|
||||||
#### **Note:** Please Avoid Modifying `require.paths`
|
#### **Note:** Please Avoid Modifying `require.paths`
|
||||||
|
|
||||||
For compatibility reasons, `require.paths` is still given first priority
|
For compatibility reasons, `require.paths` is still given first priority
|
||||||
|
@ -202,7 +202,10 @@ Module._resolveLookupPaths = function(request, parent) {
|
|||||||
var start = request.substring(0, 2);
|
var start = request.substring(0, 2);
|
||||||
if (start !== './' && start !== '..') {
|
if (start !== './' && start !== '..') {
|
||||||
var paths = Module._paths;
|
var paths = Module._paths;
|
||||||
if (parent) paths = paths.concat(parent.paths);
|
if (parent) {
|
||||||
|
if (!parent.paths) parent.paths = [];
|
||||||
|
paths = parent.paths.concat(paths);
|
||||||
|
}
|
||||||
return [request, paths];
|
return [request, paths];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +214,7 @@ Module._resolveLookupPaths = function(request, parent) {
|
|||||||
// make require('./path/to/foo') work - normally the path is taken
|
// make require('./path/to/foo') work - normally the path is taken
|
||||||
// from realpath(__filename) but with eval there is no filename
|
// from realpath(__filename) but with eval there is no filename
|
||||||
var mainPaths = ['.'].concat(Module._paths);
|
var mainPaths = ['.'].concat(Module._paths);
|
||||||
mainPaths = mainPaths.concat(Module._nodeModulePaths('.'));
|
mainPaths = Module._nodeModulePaths('.').concat(mainPaths);
|
||||||
return [request, mainPaths];
|
return [request, mainPaths];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user