diff --git a/.changeset/great-eyes-rest.md b/.changeset/great-eyes-rest.md new file mode 100644 index 000000000000..409937be6075 --- /dev/null +++ b/.changeset/great-eyes-rest.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +better error handling there whenever we don't get a normal 200 response diff --git a/packages/astro/src/cli/add/index.ts b/packages/astro/src/cli/add/index.ts index a6c4727ba92e..de27c368e0d8 100644 --- a/packages/astro/src/cli/add/index.ts +++ b/packages/astro/src/cli/add/index.ts @@ -725,10 +725,10 @@ async function fetchPackageJson( const packageName = `${scope ? `${scope}/` : ''}${name}`; const registry = await getRegistry(); const res = await fetch(`${registry}/${packageName}/${tag}`); - if (res.status === 404) { - return new Error(); - } else { + if (res.status >= 200 && res.status < 300) { return await res.json(); + } else { + return new Error(); } }