summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/node/ops/require.rs11
-rw-r--r--ext/node/polyfills/01_require.js5
2 files changed, 8 insertions, 8 deletions
diff --git a/ext/node/ops/require.rs b/ext/node/ops/require.rs
index 9e13681ae..eb092ab86 100644
--- a/ext/node/ops/require.rs
+++ b/ext/node/ops/require.rs
@@ -128,16 +128,11 @@ where
let mut current_path = from.as_path();
let mut maybe_parent = Some(current_path);
while let Some(parent) = maybe_parent {
- if !parent.ends_with("/node_modules") {
+ if !parent.ends_with("node_modules") {
paths.push(parent.join("node_modules").to_string_lossy().to_string());
- current_path = parent;
- maybe_parent = current_path.parent();
}
- }
-
- if !cfg!(windows) {
- // Append /node_modules to handle root paths.
- paths.push("/node_modules".to_string());
+ current_path = parent;
+ maybe_parent = current_path.parent();
}
Ok(paths)
diff --git a/ext/node/polyfills/01_require.js b/ext/node/polyfills/01_require.js
index 394015e31..508a32e12 100644
--- a/ext/node/polyfills/01_require.js
+++ b/ext/node/polyfills/01_require.js
@@ -607,6 +607,11 @@ Module._findPath = function (request, paths, isMain, parentPath) {
return false;
};
+/**
+ * Get a list of potential module directories
+ * @param {string} fromPath The directory name of the module
+ * @returns {string[]} List of module directories
+ */
Module._nodeModulePaths = function (fromPath) {
return ops.op_require_node_module_paths(fromPath);
};