sveltejs/kit · error · Error

@sveltejs/adapter-netlify >=2.x (possibly installed through

Error message

@sveltejs/adapter-netlify >=2.x (possibly installed through @sveltejs/adapter-auto) requires @sveltejs/kit version 1.5 or higher. Either downgrade the adapter or upgrade @sveltejs/kit

What it means

adapter-netlify 2.x relies on builder.routes, which was added to @sveltejs/kit in version 1.5 to support Netlify's split/redirect configuration. When the adapter runs with an older kit that lacks builder.routes, it throws this compatibility error during adapt().

Source

Thrown at packages/adapter-netlify/index.js:40

const files = fileURLToPath(new URL('./files', import.meta.url).href);

const edge_set_in_env_var =
	process.env.NETLIFY_SVELTEKIT_USE_EDGE === 'true' ||
	process.env.NETLIFY_SVELTEKIT_USE_EDGE === '1';

const netlify_framework_config_path = '.netlify/v1/config.json';
const netlify_framework_serverless_path = '.netlify/v1/functions';
const netlify_framework_edge_path = '.netlify/v1/edge-functions';

const FUNCTION_PREFIX = 'sveltekit-';

/** @type {typeof import('./index.js').default} */
export default function ({ split = false, edge = edge_set_in_env_var } = {}) {
	return {
		name,
		async adapt(builder) {
			if (!builder.routes) {
				throw new Error(
					'@sveltejs/adapter-netlify >=2.x (possibly installed through @sveltejs/adapter-auto) requires @sveltejs/kit version 1.5 or higher. ' +
						'Either downgrade the adapter or upgrade @sveltejs/kit'
				);
			}

			if (existsSync(`${builder.config.files.assets}/_headers`)) {
				throw new Error(
					`The _headers file should be placed in the project root rather than the ${builder.config.files.assets} directory`
				);
			}

			if (existsSync(`${builder.config.files.assets}/_redirects`)) {
				throw new Error(
					`The _redirects file should be placed in the project root rather than the ${builder.config.files.assets} directory`
				);
			}

			const netlify_config = get_netlify_config();

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Upgrade @sveltejs/kit to >= 1.5.0: pnpm install -D @sveltejs/kit@latest
  2. Delete the lockfile and reinstall to resolve a consistent kit/adapter pair
  3. Alternatively downgrade adapter-netlify to 1.x if you cannot upgrade kit

Example fix

// before (package.json)
"@sveltejs/kit": "^1.0.0",
"@sveltejs/adapter-netlify": "^2.0.0"
// after
"@sveltejs/kit": "^1.5.0",
"@sveltejs/adapter-netlify": "^2.0.0"
Defensive patterns

Strategy: validation

Validate before calling

import { version } from '@sveltejs/kit';
const [maj, min] = version.split('.').map(Number);
if (maj < 1 || (maj === 1 && min < 5)) throw new Error('adapter-netlify 2.x requires @sveltejs/kit >= 1.5');

Try / catch

try {
  await vite.build();
} catch (e) {
  if (e.message.includes('requires @sveltejs/kit version 1.5')) {
    console.error('Upgrade @sveltejs/kit: pnpm install -D @sveltejs/kit@latest');
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `vite build` with @sveltejs/adapter-netlify >= 2.x installed (often transitively via adapter-auto) while @sveltejs/kit is pinned below 1.5.0.

Common situations: Projects upgrading the adapter (or adapter-auto pulling a newer adapter) without updating kit; lockfiles pinning old kit versions; npm/yarn resolution keeping an outdated kit.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/b05a03efd769ad2a. Report an issue: GitHub.