sveltejs/kit · critical · Error

@sveltejs/adapter-bun requires Bun 1.4 or newer, but this is

Error message

@sveltejs/adapter-bun requires Bun 1.4 or newer, but this is Bun ${Bun.version}

What it means

adapter-bun uses Bun APIs (Bun.semver, Serve options) available only in Bun 1.4+. Because npm's engines.bun is not enforced at install time and builds may run on a different Bun than runtime, the adapter checks at startup with Bun.semver.order and throws if the running version is older than 1.4.0.

Source

Thrown at packages/adapter-bun/src/index.js:12

/** @import { Serve } from 'bun' */
import fs from 'node:fs';
import process from 'node:process';
import server_options from 'SERVER_OPTIONS';
import { routes } from 'ROUTES';
import { handler } from './handler.js';
import { boolean_env, bytes_env, env, number_env } from './env.js';

// nothing enforces `engines.bun` at install time, and the build may have run on a newer Bun.
// order() rather than satisfies(): a range would reject canary builds such as 1.5.0-canary.1
if (Bun.semver.order(Bun.version, '1.4.0') < 0) {
	throw new Error(
		`@sveltejs/adapter-bun requires Bun 1.4 or newer, but this is Bun ${Bun.version}`
	);
}

const options = /** @type {Serve.Options<undefined>} */ ({ ...server_options });

const unix = env('SOCKET_PATH', options.unix);

if (unix) {
	options.unix = unix;
	delete options.hostname;
	delete options.port;
	delete options.reusePort;
	delete options.ipv6Only;

	// an unclean shutdown leaves the socket file behind and the next listen would
	// fail with EADDRINUSE; the zero-size check (same heuristic as adapter-node)
	// avoids deleting a regular file that happens to sit at this path

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Upgrade Bun to 1.4 or newer: `bun upgrade` (or update your Docker base image to oven/bun:latest / a 1.4+ tag).
  2. Pin `engines.bun` in package.json and ensure CI and prod images use the same version.
  3. If you cannot upgrade, downgrade @sveltejs/adapter-bun to a version supporting your Bun release.

Example fix

// Dockerfile before
FROM oven/bun:1.2
// after
FROM oven/bun:1.4
Defensive patterns

Strategy: validation

Validate before calling

if (typeof Bun !== 'undefined' && Bun.semver.order(Bun.version, '1.4.0') < 0) {
  throw new Error(`Bun >= 1.4 required, found ${Bun.version}`);
}

Try / catch

try {
  await import('./server.js');
} catch (err) {
  if (/requires Bun 1.4 or newer/.test(err.message)) {
    console.error('Run `bun upgrade` or update the oven/bun Docker image');
  }
  throw err;
}

Prevention

When it happens

Trigger: Starting the built server on a runtime with Bun < 1.4.0 (e.g. 1.2.x/1.3.x or older canary), typically after a dependency update that raised the minimum supported Bun.

Common situations: Stale Bun on CI/production servers while local dev uses a newer version; Docker images pinning old oven/bun tags; forgetting to `bun upgrade` after adapter update.

Related errors


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