diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index cb80330947d..537258450f5 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -98,8 +98,9 @@ function updateChildren(parent, child, scan) { children.push(child); } -function Module(id, parent) { +function Module(id = '', parent) { this.id = id; + this.path = path.dirname(id); this.exports = {}; this.parent = parent; updateChildren(parent, this, false);