Skip to content

Commit bc24f57

Browse files
committed
Support relative imports from the console
1 parent e698172 commit bc24f57

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/require-hook.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ module.exports = function requireHook (opts) {
2727

2828
var loadModule = Module._load;
2929
Module._load = function(request, parent, isMain) {
30-
if (request[0] !== '.' && request[0] !== path.sep) {
30+
if (request[0] === '.') {
31+
if (parent.id === '.') {
32+
request = path.resolve(process.cwd(), request);
33+
}
34+
} else if (request[0] !== path.sep) {
3135
var pkgRoot = parent.id === '.' ? process.cwd() : path.dirname(parent.id);
3236
while (pkgRoot !== path.sep) {
3337
pkgPath = path.join(pkgRoot, 'package.json');

0 commit comments

Comments
 (0)