summaryrefslogtreecommitdiff
path: root/ext/node/polyfills
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r--ext/node/polyfills/01_require.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js
index 8fbe5078c..ce7312ee8 100644
--- a/ext/node/polyfills/01_require.js
+++ b/ext/node/polyfills/01_require.js
@@ -861,9 +861,11 @@ Module.prototype.load = function (filename) {
throw Error("Module already loaded");
}
- this.filename = filename;
+ // Canonicalize the path so it's not pointing to the symlinked directory
+ // in `node_modules` directory of the referrer.
+ this.filename = ops.op_require_real_path(filename);
this.paths = Module._nodeModulePaths(
- pathDirname(filename),
+ pathDirname(this.filename),
);
const extension = findLongestRegisteredExtension(filename);
// allow .mjs to be overriden