sveltejs/kit · error · Error

Unsupported Bun version: ${major}. Please use Bun 1.x to bui

Error message

Unsupported Bun version: ${major}. Please use Bun 1.x to build your project, or explicitly specify a runtime in your adapter configuration.

What it means

When no explicit runtime is configured, adapter-vercel infers one from the build environment. If the build ran under Bun with a major version other than 1, the adapter cannot map it to a supported Vercel Bun runtime and throws, asking for Bun 1.x or an explicit runtime.

Source

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

 * @param {string | undefined} [override_key]
 * @returns {RuntimeKey}
 */
export function resolve_runtime(default_key, override_key) {
	const key = override_key ?? default_key ?? get_default_runtime();
	assert_is_valid_runtime(key);
	return key;
}

const valid_node_versions = [22, 24];
const formatter = new Intl.ListFormat('en-gb', { type: 'disjunction' });

/** @returns {RuntimeKey} */
function get_default_runtime() {
	// if the user ran e.g. `bunx --bun vite build`, infer that they want to run the app in Bun
	if (process.versions.bun) {
		const major = process.versions.bun.split('.')[0];
		if (major !== '1') {
			throw new Error(
				`Unsupported Bun version: ${major}. Please use Bun 1.x to build your project, or explicitly specify a runtime in your adapter configuration.`
			);
		}

		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`;

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Build with Bun 1.x (`bunx --bun vite build` with Bun 1 installed) or with Node instead
  2. Explicitly set the runtime in svelte.config.js, e.g. `vercel({ runtime: 'nodejs22.x' })` or `'bun1.x'`, so inference is skipped
  3. Pin Bun 1.x in CI (e.g. oven-sh/setup-bun@v1 with bun-version: 1)
  4. Downgrade via the bun version manager if Bun 2 is installed locally

Example fix

// before
export default adapter(); // built with Bun 2.x
// after
export default adapter({ runtime: 'nodejs22.x' });
Defensive patterns

Strategy: fallback

Validate before calling

if (process.versions.bun && !process.versions.bun.startsWith('1.')) {
  console.warn('Bun != 1.x; specify adapter runtime explicitly or build with Bun 1/Node');
}

Type guard

const isBun1 = () => typeof process.versions.bun === 'string' && process.versions.bun.startsWith('1.');

Try / catch

try {
  await build();
} catch (err) {
  if (err.message.includes('Unsupported Bun version')) {
    console.error('Use Bun 1.x for the build or set adapter runtime explicitly.');
  }
  throw err;
}

Prevention

When it happens

Trigger: Running the build with a non-1.x Bun (process.versions.bun starts with '2' or higher, e.g. via `bunx --bun vite build`) while the adapter config omits `runtime`.

Common situations: Newly released Bun 2.x used out of habit with bunx; CI image upgraded Bun; team member builds with `bun run build` where the script invokes bun directly.

Related errors


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