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.
error: The entry point "src/index.js" cannot be marked as externalCommon 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
- List your
--externalflags and see which matches the entry. - Scope it to dependency names or a directory that excludes the entry.
- Re-run the build so the entry is bundled.
# externalize deps, not your own source/entry
npx esbuild src/index.js --bundle \
--external:react --external:react-dom --outfile=out.jsUse packages=external for node_modules
To externalize all dependencies without touching your entry, mark packages external instead of using a broad glob.
npx esbuild src/index.js --bundle --packages=externalHow to prevent it
- Externalize specific package names, not broad globs.
- Use
--packages=externalto keep node_modules out of the bundle. - Keep external patterns from matching your entry or source files.