summaryrefslogtreecommitdiff
path: root/cli/npm/resolution.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-10-03 19:10:53 +0200
committerGitHub <noreply@github.com>2022-10-03 19:10:53 +0200
commit5b097fd7e5224db6de65847a604f5c60a93667a0 (patch)
tree7859797288148beca4c609b3cfd83e3cae001c91 /cli/npm/resolution.rs
parent8e1b2fca59d71d2e6ab404238d7b38975adb3665 (diff)
fix(npm): better error is version is specified after subpath (#16131)
Diffstat (limited to 'cli/npm/resolution.rs')
-rw-r--r--cli/npm/resolution.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/cli/npm/resolution.rs b/cli/npm/resolution.rs
index d56cc87bc..497f40906 100644
--- a/cli/npm/resolution.rs
+++ b/cli/npm/resolution.rs
@@ -77,6 +77,18 @@ impl NpmPackageReference {
} else {
Some(parts[name_part_len..].join("/"))
};
+
+ if let Some(sub_path) = &sub_path {
+ if let Some(at_index) = sub_path.rfind('@') {
+ let (new_sub_path, version) = sub_path.split_at(at_index);
+ let msg = format!(
+ "Invalid package specifier 'npm:{}/{}'. Did you mean to write 'npm:{}{}/{}'?",
+ name, sub_path, name, version, new_sub_path
+ );
+ return Err(generic_error(msg));
+ }
+ }
+
Ok(NpmPackageReference {
req: NpmPackageReq { name, version_req },
sub_path,