Skip to content

Commit 393b355

Browse files
author
Evan Lucas
committed
module: fix regression in require ../
Fixes regression in require system that prevented loading relative packages via main property in package.json where the file is not index.{ext}. The regression was introduced in cfc1272.
1 parent 6f1d0a8 commit 393b355

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

lib/module.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ Module._findPath = function(request, paths) {
186186
}
187187
}
188188

189+
if (!filename) {
190+
filename = tryPackage(basePath, exts);
191+
}
192+
189193
if (!filename) {
190194
// try it with each of the extensions at "index"
191195
filename = tryExtensions(path.resolve(basePath, 'index'), exts);

test/fixtures/require-bin/bin/req.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../');

test/fixtures/require-bin/lib/req.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = '';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "req",
3+
"main": "./lib/req.js"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var common = require('../common');
2+
var assert = require('assert');
3+
4+
require(common.fixturesDir + '/require-bin/bin/req.js');

0 commit comments

Comments
 (0)