Skip to content

Commit 991c0c0

Browse files
committed
fix(@angular/cli): handle npm-aliased and unfetchable packages in ng update
When `ng update` encounters packages using npm aliases (`npm:` protocol) or packages that cannot be fetched from the registry (private registries, JSR, AWS CodeArtifact), the entire update process would fail with a 404 error because `Promise.all()` rejects on any single fetch failure. The fix: 1. Filters out `npm:` aliased packages early in `isPkgFromRegistry()` since the dependency key name differs from the actual package name 2. Catches individual fetch errors in the parallel metadata fetch, returning a partial result that the existing reduce logic already handles gracefully Closes #28834
1 parent 7fbc715 commit 991c0c0

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

  • packages/angular/cli/src/commands/update/schematic

packages/angular/cli/src/commands/update/schematic/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,13 @@ function _formatVersion(version: string | undefined) {
804804
* @throws When the specifier cannot be parsed.
805805
*/
806806
function isPkgFromRegistry(name: string, specifier: string): boolean {
807+
// npm: aliases (e.g., "npm:real-package@^1.0.0") resolve as registry packages
808+
// but the dependency key name differs from the actual package name, so registry
809+
// lookups using the alias name would fail with a 404.
810+
if (specifier.startsWith('npm:')) {
811+
return false;
812+
}
813+
807814
const result = npa.resolve(name, specifier);
808815

809816
return !!result.registry;
@@ -854,6 +861,12 @@ export default function (options: UpdateSchema): Rule {
854861
registry: options.registry,
855862
usingYarn,
856863
verbose: options.verbose,
864+
}).catch(() => {
865+
// Package metadata could not be fetched (e.g. private registry, npm: alias,
866+
// JSR package, or AWS CodeArtifact). Return a partial result so the reduce
867+
// below can decide whether to warn or error based on whether it was explicitly
868+
// requested.
869+
return { requestedName: depName } as Partial<NpmRepositoryPackageJson>;
857870
}),
858871
),
859872
);

0 commit comments

Comments
 (0)