Skip to content
Latchkey

esbuild "The entry point ... cannot be marked as external" in CI

An --external pattern matched the entry point you asked esbuild to bundle. esbuild cannot both build a file as the entry and treat it as external, so it rejects the configuration.

What this error means

The build fails with "The entry point 'src/index.js' cannot be marked as external" when an --external glob is broad enough to capture the entry.

esbuild
error: The entry point "src/index.js" cannot be marked as external

Common causes

An --external pattern too broad

A wildcard like --external:* or --external:./src/* matches the entry file, which must be bundled.

The entry path overlaps an externalized package name

The external specifier resolves to the same path as the entry, so esbuild sees a contradiction.

How to fix it

Narrow the external pattern

  1. List your --external flags and see which matches the entry.
  2. Scope it to dependency names or a directory that excludes the entry.
  3. Re-run the build so the entry is bundled.
Terminal
# externalize deps, not your own source/entry
npx esbuild src/index.js --bundle \
  --external:react --external:react-dom --outfile=out.js

Use packages=external for node_modules

To externalize all dependencies without touching your entry, mark packages external instead of using a broad glob.

Terminal
npx esbuild src/index.js --bundle --packages=external

How to prevent it

  • Externalize specific package names, not broad globs.
  • Use --packages=external to keep node_modules out of the bundle.
  • Keep external patterns from matching your entry or source files.

Frequently asked questions

What causes ""entry point cannot be marked as external""?
A wildcard like --external:* or --external:./src/* matches the entry file, which must be bundled.
How do I fix "entry point cannot be marked as external"?
Narrow the external pattern

Related guides

References

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