evanw/esbuild · error · Error

Invalid ${what}: ${value}

Error message

Invalid ${what}: ${value}

What it means

Error "Invalid ${what}: ${value}" thrown in evanw/esbuild.

Source

Thrown at lib/shared/common.ts:16

import type * as types from "./types"
import * as protocol from "./stdio_protocol"
import { JSON_parse } from "./uint8array_json_parser"

declare const ESBUILD_VERSION: string

const quote: (x: string) => string = JSON.stringify

const buildLogLevelDefault = 'warning'
const transformLogLevelDefault = 'silent'

function validateAndJoinStringArray(values: string[], what: string): string {
  const toJoin: string[] = []
  for (const value of values) {
    validateStringValue(value, what)
    if (value.indexOf(',') >= 0) throw new Error(`Invalid ${what}: ${value}`)
    toJoin.push(value)
  }
  return toJoin.join(',')
}

let canBeAnything = () => null

let mustBeBoolean = (value: boolean | undefined): string | null =>
  typeof value === 'boolean' ? null : 'a boolean'

let mustBeString = (value: string | undefined): string | null =>
  typeof value === 'string' ? null : 'a string'

let mustBeRegExp = (value: RegExp | undefined): string | null =>
  value instanceof RegExp ? null : 'a RegExp object'

let mustBeInteger = (value: number | undefined): string | null =>
  typeof value === 'number' && value === (value | 0) ? null : 'an integer'

View on GitHub (pinned to 6ff1d8b0d8)

Solutions

  1. Pass a valid value for the option: check that the value matches the expected type or format
  2. Consult the esbuild API documentation for the allowed values of this option

Example fix

// e.g. charset must be "ascii" or "utf8"
esbuild.buildSync({ charset: 'utf8', ... });

When it happens

Trigger: Thrown at lib/shared/common.ts:16 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of evanw/esbuild@6ff1d8b0d8 (2026-08-03). Data as JSON: /data/errors/b590475beccf915e.json. Report an issue: GitHub.