withastro/astro · error · Error

Unable to fetch . Does the package exist?

Error message

Unable to fetch ${integration}. Does the package exist?

What it means

Thrown by `astro add` when a third-party package cannot be fetched from the npm registry. After determining the target is third-party (explicit non-@astrojs scope, or the user accepted the fallback), Astro calls fetchPackageJson(scope, name, tag); any Error result — a non-2xx registry response such as 404, or a failed fetch — aborts the add, because Astro needs the package.json to build the install plan.

Solutions

  1. Verify the package exists and is reachable: `npm view @scope/name version` (use the same package manager you build with)
  2. Fix the name, scope, or tag and re-run `astro add @scope/name@latest`
  3. Check your registry configuration (`npm config get registry`, or the pnpm/yarn equivalent) and point it at a registry that serves the package
  4. If offline or behind a proxy, configure HTTPS_PROXY / corporate registry before retrying

Example fix

# before
astro add @my-org/astro-thing   # Unable to fetch @my-org/astro-thing. Does the package exist?

# after
npm view @my-org/astro-thing version   # confirm name/tag resolve on your registry
astro add @my-org/astro-thing@latest
Defensive patterns

Strategy: validation

Validate before calling

import { execSync } from 'node:child_process';

// resolve the exact spec against the same registry astro will use
function packageIsFetchable(spec) {
  try {
    execSync(`npm view ${spec} version`, { stdio: ['pipe', 'pipe', 'ignore'] });
    return true;
  } catch {
    return false;
  }
}

if (!packageIsFetchable('@my-org/astro-thing@latest')) {
  // fix name/tag or registry before running astro add
}

Try / catch

import { spawnSync } from 'node:child_process';
const r = spawnSync('astro', ['add', spec], { encoding: 'utf8' });
if (r.status !== 0 && /Does the package exist\?/.test(r.stderr)) {
  // name/tag/registry problem — verify spec with `npm view` and retry once corrected
}

Prevention

When it happens

Trigger: `astro add @scope/name` where `${registry}/@scope/name/<tag>` returns 404/5xx or the network request fails; also `astro add pkg@sometag` with a dist-tag that does not exist.

Common situations: Typo in scope or package name, package unpublished or made private, corporate registry mirror that has not synced the package, offline machine or HTTP proxy blocking registry traffic, wrong dist-tag.

Related errors


AI-assisted analysis of withastro/astro@e294953aa8 (2026-08-18). Data as JSON: /api/errors/af0d73c6602a0978. Report an issue: GitHub.

Appendix: source

Thrown at packages/astro/src/cli/add/index.ts:892

								`No problem! Find our official integrations at ${cyan(
									'https://astro.build/integrations',
								)}`,
							);
						}
						spinner.message('Resolving with third party packages...');
						pkgType = 'third-party';
					} else {
						pkgType = 'first-party';
						pkgJson = firstPartyPkgCheck as any;
					}
				}
				if (pkgType === 'third-party') {
					const thirdPartyPkgCheck = await fetchPackageJson(scope, name, tag);
					if (thirdPartyPkgCheck instanceof Error) {
						if (thirdPartyPkgCheck.message) {
							spinner.message(yellow(thirdPartyPkgCheck.message));
						}
						throw new Error(`Unable to fetch ${bold(integration)}. Does the package exist?`);
					} else {
						pkgJson = thirdPartyPkgCheck as any;
					}
				}

				const resolvedScope = pkgType === 'first-party' ? '@astrojs' : scope;
				const packageName = `${resolvedScope ? `${resolvedScope}/` : ''}${name}`;
				let integrationName = packageName;
				let dependencies: IntegrationInfo['dependencies'] = [
					[pkgJson['name'], `^${pkgJson['version']}`],
				];

				if (pkgJson['peerDependencies']) {
					const meta = pkgJson['peerDependenciesMeta'] || {};
					for (const peer in pkgJson['peerDependencies']) {
						const optional = meta[peer]?.optional || false;
						const isAstro = peer === 'astro';
						if (!optional && !isAstro) {

View on GitHub (pinned to e294953aa8)