Skip to content
Latchkey

esbuild "Transform failed with N errors" in CI

esbuild tried to transform a file and hit a parse or syntax error. The file uses syntax esbuild cannot read with its current loader or target, so it aborts and reports each transform error.

What this error means

The build fails with "Transform failed with 1 error:" followed by a file location and an "ERROR:" describing the syntax esbuild could not handle.

esbuild
Transform failed with 1 error:
src/legacy.js:12:8: ERROR: Expected ";" but found "const"

Common causes

A genuine syntax error in the source

The file contains invalid JavaScript or TypeScript that esbuild cannot parse.

Syntax newer than the configured target or wrong loader

A feature beyond the --target, or a file transformed with the wrong loader (JSX as JS), trips the parser.

How to fix it

Fix the syntax at the reported location

  1. Open the file at the line/column in the error.
  2. Correct the invalid syntax.
  3. Re-run the build to confirm the transform succeeds.

Set the right loader or target

Tell esbuild how to read the file and which syntax level to accept.

Terminal
npx esbuild src/app.jsx --bundle \
  --loader:.jsx=jsx --target=es2020

How to prevent it

  • Lint and type-check before building so syntax errors surface early.
  • Set --target to match the syntax your code uses.
  • Map each non-standard extension to the correct loader.

Frequently asked questions

What causes ""Transform failed with errors""?
The file contains invalid JavaScript or TypeScript that esbuild cannot parse.
How do I fix "Transform failed with errors"?
Fix the syntax at the reported location

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card