diff --git a/.changeset/real-nails-tan.md b/.changeset/real-nails-tan.md new file mode 100644 index 000000000000..9e78e35de3bf --- /dev/null +++ b/.changeset/real-nails-tan.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix installing non-stable versions of integrations with `astro add` diff --git a/packages/astro/src/cli/add/index.ts b/packages/astro/src/cli/add/index.ts index 7866f5a093ab..449deee5f3fa 100644 --- a/packages/astro/src/cli/add/index.ts +++ b/packages/astro/src/cli/add/index.ts @@ -608,7 +608,8 @@ async function resolveRangeToInstallSpecifier(name: string, range: string): Prom if (versions instanceof Error) return name; // Filter out any prerelease versions, but fallback if there are no stable versions const stableVersions = versions.filter((v) => !v.includes('-')); - const maxStable = maxSatisfying(stableVersions.length !== 0 ? stableVersions : versions, range); + const maxStable = maxSatisfying(stableVersions, range) ?? maxSatisfying(versions, range); + if (!maxStable) return name; return `${name}@^${maxStable}`; }