Fix undefined error when adding scoped package on yarn, npm or npx

This commit is contained in:
Sander Declerck 2025-08-16 19:45:51 +02:00
parent b57cc11157
commit 9e1c90a914
No known key found for this signature in database
7 changed files with 41 additions and 3 deletions

View file

@ -86,7 +86,9 @@ function parsePackagename(arg) {
const lastAtIndex = arg.lastIndexOf("@");
let name, version;
if (lastAtIndex !== -1) {
// The index of the last "@" should be greater than 0
// If the index is 0, it means the package name starts with "@" (eg: "@vercel/otel")
if (lastAtIndex > 0) {
name = arg.slice(0, lastAtIndex);
version = arg.slice(lastAtIndex + 1);
} else {