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.
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
- Open the file at the line/column in the error.
- Correct the invalid syntax.
- 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.
npx esbuild src/app.jsx --bundle \
--loader:.jsx=jsx --target=es2020How to prevent it
- Lint and type-check before building so syntax errors surface early.
- Set
--targetto match the syntax your code uses. - Map each non-standard extension to the correct loader.