evanw/esbuild · error · Error
Invalid option ${where}: ${quote(key)}
Error message
Invalid option ${where}: ${quote(key)} What it means
Error "Invalid option ${where}: ${quote(key)}" thrown in evanw/esbuild.
Source
Thrown at lib/shared/common.ts:89
let mustBeStringOrURL = (value: string | URL | undefined): string | null =>
typeof value === 'string' || value instanceof URL ? null : 'a string or a URL'
type OptionKeys = { [key: string]: boolean }
function getFlag<T, K extends (keyof T & string)>(object: T, keys: OptionKeys, key: K, mustBeFn: (value: T[K]) => string | null): T[K] | undefined {
let value = object[key]
keys[key + ''] = true
if (value === undefined) return undefined
let mustBe = mustBeFn(value)
if (mustBe !== null) throw new Error(`${quote(key)} must be ${mustBe}`)
return value
}
function checkForInvalidFlags(object: Object, keys: OptionKeys, where: string): void {
for (let key in object) {
if (!(key in keys)) {
throw new Error(`Invalid option ${where}: ${quote(key)}`)
}
}
}
export function validateInitializeOptions(options: types.InitializeOptions): types.InitializeOptions {
let keys: OptionKeys = Object.create(null)
let wasmURL = getFlag(options, keys, 'wasmURL', mustBeStringOrURL)
let wasmModule = getFlag(options, keys, 'wasmModule', mustBeWebAssemblyModule)
let worker = getFlag(options, keys, 'worker', mustBeBoolean)
checkForInvalidFlags(options, keys, 'in initialize() call')
return {
wasmURL,
wasmModule,
worker,
}
}
type MangleCache = Record<string, string | false>View on GitHub (pinned to 6ff1d8b0d8)
Solutions
- Remove the invalid option or fix its name; it is not recognized in this context
- Check for typos in option names and verify the option belongs to the API call being used
Example fix
// "globalName" is only valid for build, not transform
esbuild.buildSync({ globalName: 'myLib', format: 'iife' }); When it happens
Trigger: Thrown at lib/shared/common.ts:89 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/421ecda677d91089.json.
Report an issue: GitHub.