diff options
Diffstat (limited to 'cli/npm/resolution.rs')
-rw-r--r-- | cli/npm/resolution.rs | 12 |
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, |