GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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
Filter options
  • lib
    • module.js
  • test/parallel
    • test-module-relative-lookup.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/module.js‎

Copy file name to clipboardExpand all lines: lib/module.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ Module._resolveLookupPaths = function(request, parent) {
250250
if (!parent || !parent.id || !parent.filename) {
251251
// make require('./path/to/foo') work - normally the path is taken
252252
// 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);
255254
return [request, mainPaths];
256255
}
257256

Collapse file

‎test/parallel/test-module-relative-lookup.js‎

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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');

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.