Skip to content

Commit 4e14a7e

Browse files
committed
fix(@angular/cli): improve error handling and logging for package manager installation failures during CLI updates
Enhance error reporting when package manager installations fail by extracting and logging the command's detailed output (stdout/stderr).
1 parent 75c1dce commit 4e14a7e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

packages/angular/cli/lib/cli/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { logging } from '@angular-devkit/core';
1010
import { format, stripVTControlCharacters } from 'node:util';
1111
import { CommandModuleError } from '../../src/command-builder/command-module';
1212
import { runCommand } from '../../src/command-builder/command-runner';
13+
import { PackageManagerError } from '../../src/package-managers';
1314
import { colors, supportColor } from '../../src/utilities/color';
1415
import { ngDebug } from '../../src/utilities/environment-options';
1516
import { writeErrorToLogFile } from '../../src/utilities/log-file';
@@ -80,6 +81,10 @@ export default async function (options: { cliArgs: string[] }) {
8081
} catch (err) {
8182
if (err instanceof CommandModuleError) {
8283
logger.fatal(`Error: ${err.message}`);
84+
} else if (err instanceof PackageManagerError) {
85+
const errorMessage = `Error: Package installation failed ${err.message}`;
86+
const output = err.stderr || err.stdout;
87+
logger.fatal(output ? `${errorMessage}\n${output}` : errorMessage);
8388
} else if (err instanceof Error) {
8489
try {
8590
const logPath = writeErrorToLogFile(err);

0 commit comments

Comments
 (0)