withastro/astro · error · Error

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

Error message

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

What it means

When the resolved package is third-party (scope is not @astrojs, or @astrojs lookup failed and the user chose to continue), `astro add` calls fetchPackageJson for that scope/name/tag. If that lookup returns an Error (registry lookup failed, package not found), `astro add` throws this Error. It indicates the package genuinely could not be located on the registry.

Source

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

								`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 d081033d5f)

Solutions

  1. Verify the package exists on npm: `npm view <pkg>` or search the registry.
  2. Correct the spelling / scope and re-run `astro add`.
  3. If you are behind a registry mirror/proxy, ensure npm/Astro can reach it (check .npmrc and network).
  4. If the package is private, install it manually via your package manager instead of `astro add`.

Example fix

# before
astro add @astrojs/tailwnd   # name typo, lookup fails

# after
astro add @astrojs/tailwind
Defensive patterns

Strategy: validation

Validate before calling

async function packageExists(name: string, tag = 'latest') {
  const r = await fetch(`https://registry.npmjs.org/${encodeURIComponent(name)}/${tag}`);
  return r.ok;
}

Type guard

function isScopedName(v: unknown): v is string {
  return typeof v === 'string' && /^@[^/]+\//.test(v);
}

Prevention

When it happens

Trigger: Running `astro add @scope/nonexistent` or `astro add typoed-name` where the package does not exist on the npm registry (or the registry was unreachable during resolution). Reached in the third-party branch after the official-package check failed.

Common situations: Typo in the package name; private/unpublished package; registry downtime or network egress block; scoped package whose scope is correct but name is wrong; package was renamed/deprecated.

Related errors


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