withastro/astro · warning

Unable to fetch latest ${packageName} version from the npm r

Error message

Unable to fetch latest ${packageName} version from the npm registry. Using ${fallbackName} instead.

What it means

create-astro resolves which template/package version to use by fetching `${registry}/${packageName}/${tag}` (default tag 'latest') with a 10-second AbortSignal timeout. If the fetch or JSON parse fails, the .catch handler logs this warning and resolves with the fallback (or the literal 'latest') — scaffolding continues, just with the fallback version choice.

Source

Thrown at packages/create-astro/src/messages.ts:69

		});
	});

export const getVersion = (
	packageManager: string,
	packageName: string,
	packageTag = 'latest',
	fallback = '',
) =>
	new Promise<string>(async (resolve) => {
		let registry = await getRegistry(packageManager);
		const { version } = await fetch(`${registry}/${packageName}/${packageTag}`, {
			redirect: 'follow',
			signal: AbortSignal.timeout(10_000),
		})
			.then((res) => res.json())
			.catch(() => {
				const fallbackName = fallback || `'latest'`;
				console.warn(
					`Unable to fetch latest ${packageName} version from the npm registry. Using ${fallbackName} instead.`,
				);
				return { version: fallback };
			});
		return resolve(version);
	});

export const log = (message: string) => stdout.write(message + '\n');
export const banner = () => {
	const prefix = `astro`;
	const suffix = `Launch sequence initiated.`;
	log(`${label(prefix, color.bgGreen, color.black)}  ${suffix}`);
};

export const bannerAbort = () =>
	log(`\n${label('astro', color.bgRed)} ${color.bold('Launch sequence aborted.')}`);

export const info = async (prefix: string, text: string) => {

View on GitHub (pinned to 52e6c34790)

Solutions

  1. Pass an explicit --template so the version choice does not depend on the registry lookup
  2. Fix registry connectivity: check `npm config get registry`, proxy env vars (HTTPS_PROXY/HTTP_PROXY), and run `npm ping`
  3. Retry once the network or registry recovers — the tool already fell back safely, so nothing is half-installed
  4. Pin a specific tag/version in your scaffolding docs so the fallback path is the expected path

Example fix

# before (relies on the 'latest' registry lookup)
npm create astro@latest my-app

# after (explicit template; lookup failure no longer changes the outcome)
npm create astro@latest my-app -- --template basics
Defensive patterns

Strategy: retry

Validate before calling

# Verify registry reachability before scaffolding
npm ping && npm config get registry

Prevention

When it happens

Trigger: Running `npm create astro` (or create-astro directly) with no network egress to the registry; a custom registry that is down or returns non-JSON (HTML error pages); proxies blocking registry.npmjs.org; slow networks exceeding the 10s timeout.

Common situations: CI runners with restricted egress; offline onboarding; corporate Artifactory/Nexus mirrors misconfigured in .npmrc; npm outages; the warning is benign but signals the chosen version may not be what you expected.

Related errors


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