evanw/esbuild · error · Error

Unsupported platform

Error message

Unsupported platform: ${platformKey}

What it means

pkgAndSubpathForCurrentPlatform (lib/npm/node-platform.ts:57) builds a platformKey from `${process.platform} ${os.arch()} ${os.endianness()}` and looks it up in knownWindowsPackages, knownUnixlikePackages, then knownWebAssemblyFallbackPackages. If it matches none, esbuild has no prebuilt binary for that OS/arch/endianness combination and throws. This is an environment esbuild simply does not ship a native binary for.

Solutions

  1. Use the esbuild-wasm package, which is platform-independent.
  2. Build esbuild from source for your platform (it is written in Go).
  3. Run your build inside a container/VM with a supported platform.
  4. Open an issue / contribute a platform package if demand justifies it.
Defensive patterns

Strategy: fallback

Validate before calling

// Detect an unsupported platform up front and choose esbuild-wasm.
const os = require('os')
const known = require('./known-platforms.json') // mirror esbuild's package maps
const key = `${process.platform} ${os.arch()} ${os.endianness()}`
if (!known.includes(key)) {
  console.warn('Unsupported native platform; use esbuild-wasm')
}

Prevention

When it happens

Trigger: Running esbuild (install or at runtime via generateBinPath) on an OS/architecture combination for which esbuild publishes no platform package.

Common situations: Niche or new CPU architectures (rare RISC boards); an OS esbuild doesn't target; unusual endianness; a custom Node build reporting an exotic platform string.

Related errors


AI-assisted analysis of evanw/esbuild@f6058f8364 (2026-08-09). Data as JSON: /api/errors/03940046709103e1. Report an issue: GitHub.

Appendix: source

Thrown at lib/npm/node-platform.ts:80

  if (platformKey in knownWindowsPackages) {
    pkg = knownWindowsPackages[platformKey]
    subpath = 'esbuild.exe'
  }

  else if (platformKey in knownUnixlikePackages) {
    pkg = knownUnixlikePackages[platformKey]
    subpath = 'bin/esbuild'
  }

  else if (platformKey in knownWebAssemblyFallbackPackages) {
    pkg = knownWebAssemblyFallbackPackages[platformKey]
    subpath = 'bin/esbuild'
    isWASM = true
  }

  else {
    throw new Error(`Unsupported platform: ${platformKey}`)
  }

  return { pkg, subpath, isWASM }
}

function pkgForSomeOtherPlatform(): string | null {
  const libMainJS = require.resolve('esbuild')
  const nodeModulesDirectory = path.dirname(path.dirname(path.dirname(libMainJS)))

  if (path.basename(nodeModulesDirectory) === 'node_modules') {
    for (const unixKey in knownUnixlikePackages) {
      try {
        const pkg = knownUnixlikePackages[unixKey]
        if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg
      } catch {
      }
    }

View on GitHub (pinned to f6058f8364)