From 3b4e629ac8c2fdb4b491bf01abc7794e2e100173 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 4 Jan 2024 19:16:53 +0800 Subject: [PATCH] Improve astro add deps error reporting (#9593) --- .changeset/afraid-socks-rescue.md | 5 +++++ packages/astro/src/cli/add/index.ts | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/afraid-socks-rescue.md diff --git a/.changeset/afraid-socks-rescue.md b/.changeset/afraid-socks-rescue.md new file mode 100644 index 000000000000..b5a9c587e526 --- /dev/null +++ b/.changeset/afraid-socks-rescue.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Improves `astro add` error reporting when the dependencies fail to install diff --git a/packages/astro/src/cli/add/index.ts b/packages/astro/src/cli/add/index.ts index 1240e67deed0..74a4f73626f2 100644 --- a/packages/astro/src/cli/add/index.ts +++ b/packages/astro/src/cli/add/index.ts @@ -732,11 +732,12 @@ async function tryToInstallIntegrations({ ); spinner.succeed(); return UpdateResult.updated; - } catch (err) { + } catch (err: any) { spinner.fail(); logger.debug('add', 'Error installing dependencies', err); + // NOTE: `err.stdout` can be an empty string, so log the full error instead for a more helpful log // eslint-disable-next-line no-console - console.error('\n', (err as any).stdout, '\n'); + console.error('\n', err.stdout || err.message, '\n'); return UpdateResult.failure; } } else {