GeezerVison is showing github.com — module: prioritize current dir for local lookups · lightsofapollo/node@d38503a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/module.js +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -250,8 +250,7 @@ Module._resolveLookupPaths = function(request, parent) { |
250 | 250 | if (!parent || !parent.id || !parent.filename) { |
251 | 251 | // make require('./path/to/foo') work - normally the path is taken |
252 | 252 | // from realpath(__filename) but with eval there is no filename |
253 | | - var mainPaths = ['.'].concat(modulePaths); |
254 | | - mainPaths = Module._nodeModulePaths('.').concat(mainPaths); |
| 253 | + var mainPaths = ['.'].concat(Module._nodeModulePaths('.'), modulePaths); |
255 | 254 | return [request, mainPaths]; |
256 | 255 | } |
257 | 256 |
|
|
Collapse file
Copy file name to clipboard +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +require('../common'); |
| 4 | +const assert = require('assert'); |
| 5 | +const _module = require('module'); // avoid collision with global.module |
| 6 | +const lookupResults = _module._resolveLookupPaths('./lodash'); |
| 7 | +const paths = lookupResults[1]; |
| 8 | + |
| 9 | +assert.strictEqual(paths[0], '.', |
| 10 | + 'Current directory is prioritized before node_modules for local modules'); |