From 8d8a7105e0dbe0d100b57811018ad882783022e5 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 2 Apr 2026 10:18:17 -0400 Subject: [PATCH] fix(@angular/cli): handle missing package manager during analytics initialization Wrap getVersion() call in try-catch to prevent a crash during analytics setup when the package manager is not available. --- .../cli/src/command-builder/command-module.ts | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/angular/cli/src/command-builder/command-module.ts b/packages/angular/cli/src/command-builder/command-module.ts index e5cc6f70473a..b0d15d70d0b2 100644 --- a/packages/angular/cli/src/command-builder/command-module.ts +++ b/packages/angular/cli/src/command-builder/command-module.ts @@ -153,12 +153,21 @@ export abstract class CommandModule implements CommandModuleI ['version', 'update', 'analytics'].includes(this.commandName), ); - return userId - ? new AnalyticsCollector(this.context.logger, userId, { - name: this.context.packageManager.name, - version: await this.context.packageManager.getVersion(), - }) - : undefined; + if (!userId) { + return undefined; + } + + let version: string | undefined; + try { + version = await this.context.packageManager.getVersion(); + } catch { + // Ignore errors if the package manager is not available. + } + + return new AnalyticsCollector(this.context.logger, userId, { + name: this.context.packageManager.name, + version, + }); } /**