summaryrefslogtreecommitdiff
path: root/ext/node/resolution.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-05-04 02:48:23 +0200
committerGitHub <noreply@github.com>2023-05-04 00:48:23 +0000
commitb8d0e616eaedb81a759c41d5009921bcc6b0b0bf (patch)
treecb90dede32bd79c8c9063cb9649c603039c45fa2 /ext/node/resolution.rs
parent7a8bb3b611f02b272b1c19b6f3d8a85b099ca317 (diff)
fix(npm): canonicalize search directory when looking for package.json (#18981)
Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'ext/node/resolution.rs')
-rw-r--r--ext/node/resolution.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/node/resolution.rs b/ext/node/resolution.rs
index 0c90fffb6..046c774fa 100644
--- a/ext/node/resolution.rs
+++ b/ext/node/resolution.rs
@@ -1078,14 +1078,17 @@ impl NodeResolver {
url: &ModuleSpecifier,
) -> Result<PathBuf, AnyError> {
let file_path = url.to_file_path().unwrap();
- let mut current_dir = file_path.parent().unwrap();
+ let current_dir = deno_core::strip_unc_prefix(
+ self.fs.canonicalize(file_path.parent().unwrap())?,
+ );
+ let mut current_dir = current_dir.as_path();
let package_json_path = current_dir.join("package.json");
if self.fs.exists(&package_json_path) {
return Ok(package_json_path);
}
let root_pkg_folder = self
.npm_resolver
- .resolve_package_folder_from_path(&url.to_file_path().unwrap())?;
+ .resolve_package_folder_from_path(current_dir)?;
while current_dir.starts_with(&root_pkg_folder) {
current_dir = current_dir.parent().unwrap();
let package_json_path = current_dir.join("package.json");