sveltejs/kit · error · Error

Could not auto-detect a runtime. Please explicitly specify a

Error message

Could not auto-detect a runtime. Please explicitly specify a runtime in your adapter configuration.

What it means

The Vercel adapter tries to auto-detect the serverless runtime from the environment (checking the installed Node.js major version). When it cannot determine a supported version, it throws and asks you to set `runtime` explicitly in the adapter options in svelte.config.js.

Source

Thrown at packages/adapter-vercel/utils.js:102

		}

		return `bun${major}.x`;
	}

	// otherwise, default to the version of Node specified in the project config
	if (process.versions.node) {
		const major = Number(process.versions.node.split('.')[0]);

		if (!valid_node_versions.includes(major)) {
			throw new Error(
				`Unsupported Node.js version: ${process.version}. Please use Node ${formatter.format(valid_node_versions.map((v) => `${v}`))} to build your project, or explicitly specify a runtime in your adapter configuration.`
			);
		}

		return `nodejs${/** @type {22 | 24} */ (major)}.x`;
	}

	throw new Error(
		'Could not auto-detect a runtime. Please explicitly specify a runtime in your adapter configuration.'
	);
}

const valid_runtimes = /** @type {const} */ (['nodejs22.x', 'nodejs24.x', 'bun1.x']);

/**
 * @param {string} key
 * @returns {asserts key is RuntimeKey}
 */
function assert_is_valid_runtime(key) {
	if (!valid_runtimes.includes(/** @type {RuntimeKey} */ (key))) {
		throw new Error(
			`Unsupported runtime: ${key}. Supported runtimes are: ${valid_runtimes.join(', ')}. See the Node.js Version section in your Vercel project settings for info on the currently supported versions.`
		);
	}
}

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Set `runtime: 'nodejs22.x'` (or 'nodejs24.x' / 'bun1.x') in the vercel adapter options in svelte.config.js
  2. Upgrade or pin the build environment to Node.js 22 or 24 so auto-detection succeeds
  3. Check that the CI/container is not running an EOL Node version

Example fix

// before (svelte.config.js)
adapter: adapter()
// after
adapter: adapter({ runtime: 'nodejs22.x' })
Defensive patterns

Strategy: validation

Validate before calling

// in svelte.config.js, before building
const supported = ['nodejs22.x', 'nodejs24.x', 'bun1.x'];
if (!supported.includes(adapterOptions.runtime ?? '')) {
  console.warn('Set adapter({ runtime }) explicitly; auto-detect will fail on this Node version:', process.version);
}

Prevention

When it happens

Trigger: Calling `key`/`get_default_runtime` during build when neither a recognizable Node.js major version (22 or 24) nor another detectable runtime is present in the build environment.

Common situations: Building on a Node version outside the supported set (e.g. Node 18/20/26), building in a container/CI where node version detection fails, or using Bun/edge without specifying runtime.

Related errors


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