diff --git a/pkgs/build-support/node/prefetch-npm-deps/src/parse/lock.rs b/pkgs/build-support/node/prefetch-npm-deps/src/parse/lock.rs index 17c6c633ee8f..266ba2585913 100644 --- a/pkgs/build-support/node/prefetch-npm-deps/src/parse/lock.rs +++ b/pkgs/build-support/node/prefetch-npm-deps/src/parse/lock.rs @@ -25,7 +25,12 @@ pub(super) fn packages(content: &str) -> anyhow::Result> { .unwrap_or_default() .into_iter() .filter(|(n, p)| !n.is_empty() && matches!(p.resolved, Some(UrlOrString::Url(_)))) - .map(|(n, p)| Package { name: Some(n), ..p }) + .map(|(n, p)| Package { + // Use the package's own name if present (for aliases like string-width-cjs -> string-width), + // otherwise extract from the lockfile key + name: Some(p.name.unwrap_or(n)), + ..p + }) .collect(), _ => bail!( "We don't support lockfile version {}, please file an issue.",