biomejs/biome · error · Error

Unknown distribution: ${distribution}

Error message

Unknown distribution: ${distribution}

What it means

Biome.create() maps the Distribution enum to one of three WASM packages: BUNDLER (0) -> @biomejs/wasm-bundler, NODE (1) -> @biomejs/wasm-nodejs, WEB (2) -> @biomejs/wasm-web (js-api/src/index.ts:52-62). Any other value falls through the switch to the default arm and throws, because there is no WASM module to import for it.

Source

Thrown at packages/@biomejs/js-api/src/index.ts:61

export interface BiomeCreate {
	distribution: Distribution;
}

export class Biome extends BiomeCommon<Configuration, Diagnostic> {
	/**
	 * It creates a new instance of the class {Biome}.
	 */
	static async create({ distribution }: BiomeCreate): Promise<Biome> {
		switch (distribution) {
			case Distribution.BUNDLER:
				return new Biome(await import("@biomejs/wasm-bundler"));
			case Distribution.NODE:
				return new Biome(await import("@biomejs/wasm-nodejs"));
			case Distribution.WEB:
				return new Biome(await import("@biomejs/wasm-web"));
			default:
				throw new Error(`Unknown distribution: ${distribution}`);
		}
	}
}

View on GitHub (pinned to 7529811358)

Solutions

  1. Import Distribution from @biomejs/js-api and pass the enum member: Distribution.NODE for Node.js, Distribution.WEB for browsers, Distribution.BUNDLER for bundlers.
  2. If the value comes from config or env, validate it against Object.values(Distribution) before calling Biome.create.
  3. Ensure the matching @biomejs/wasm-* package for the chosen distribution is installed in the project.

Example fix

// before
const biome = await Biome.create({ distribution: "node" });

// after
import { Biome, Distribution } from "@biomejs/js-api";
const biome = await Biome.create({ distribution: Distribution.NODE });
Defensive patterns

Strategy: type-guard

Validate before calling

import { Biome, Distribution } from "@biomejs/js-api";

if (!Object.values(Distribution).includes(distribution)) {
	throw new Error(`Invalid distribution ${String(distribution)}; use Distribution.NODE, Distribution.WEB, or Distribution.BUNDLER`);
}
const biome = await Biome.create({ distribution });

Type guard

import { Distribution } from "@biomejs/js-api";

function isValidDistribution(value: unknown): value is Distribution {
	return typeof value === "number" && value in Distribution;
}

// usage
if (!isValidDistribution(config.distribution)) {
	throw new Error("distribution must be one of the Distribution enum members");
}
const biome = await Biome.create({ distribution: config.distribution });

Try / catch

try {
	const biome = await Biome.create({ distribution });
} catch (err) {
	if (err instanceof Error && err.message.startsWith("Unknown distribution:")) {
		// re-raise with user-facing guidance
		throw new Error(`Unsupported distribution ${String(distribution)}. Pass Distribution.NODE, Distribution.WEB, or Distribution.BUNDLER.`);
	}
	throw err;
}

Prevention

When it happens

Trigger: Calling Biome.create({ distribution: "node" }) with a string instead of the enum member; passing undefined because the property is missing or misnamed in the object literal; passing a number from config that does not equal 0, 1, or 2; stale serialized enum values after an upgrade renumbers the enum.

Common situations: Copying example code that uses strings; reading the distribution from CLI args, environment, or JSON config without validation; upgrading @biomejs/js-api across releases where the enum changed shape; forgetting that the enum must be imported from @biomejs/js-api itself.

Related errors


AI-assisted analysis of biomejs/biome@7529811358 (2026-08-16). Data as JSON: /api/errors/20735e1ba502e60d. Report an issue: GitHub.