angular/angular-cli · error · Error
esbuild implementation missing
Error message
esbuild implementation missing
What it means
The EsbuildExecutor class stubs its transform/formatMessages methods with functions that throw this error until a real esbuild implementation (native or WASM) is loaded. The constructor assigns throwing placeholders so any call before successful initialization fails loudly. It indicates that esbuild could not be initialized in this executor instance, not that esbuild is missing from node_modules.
Source
Thrown at packages/angular_devkit/build_angular/src/tools/webpack/plugins/esbuild-executor.ts:38
* At first use of esbuild, a supportability test will be automatically performed and the
* WASM-variant will be used if needed by the platform.
*/
export class EsbuildExecutor
implements Pick<typeof import('esbuild'), 'transform' | 'formatMessages'>
{
private esbuildTransform: this['transform'];
private esbuildFormatMessages: this['formatMessages'];
private initialized = false;
/**
* Constructs an instance of the `EsbuildExecutor` class.
*
* @param alwaysUseWasm If true, the WASM-variant will be preferred and no support test will be
* performed; if false (default), the native variant will be preferred.
*/
constructor(private alwaysUseWasm = false) {
this.esbuildTransform = this.esbuildFormatMessages = () => {
throw new Error('esbuild implementation missing');
};
}
/**
* Determines whether the native variant of esbuild can be used on the current platform.
*
* @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.
*/
static async hasNativeSupport(): Promise<boolean> {
// Try to use native variant to ensure it is functional for the platform.
try {
const { formatMessages } = await import('esbuild');
await formatMessages([], { kind: 'error' });
return true;
} catch {
return false;
}View on GitHub (pinned to bb72145f9a)
Solutions
- Reinstall dependencies cleanly: delete node_modules and lockfile, then run npm install so the correct esbuild optional dependency for your platform is installed
- Ensure optional dependencies are not skipped (avoid --omit=optional) since esbuild ships platform-specific native binaries as optionalDependencies
- If on an exotic platform where native esbuild is unavailable, construct EsbuildExecutor with alwaysUseWasm=true so the WASM variant is used
- Verify the platform/CPU is supported by esbuild and that no postinstall scripts are disabled (npm config ignore-scripts must be false)
Example fix
// before (package.json)
{"scripts": {"install": "npm install --omit=optional"}}
// after
{"scripts": {"install": "npm install"}} Defensive patterns
Strategy: fallback
Validate before calling
const executor = new EsbuildExecutor(wasm);
await executor.load(true).catch(() => new EsbuildExecutor(true).load(true));
if (typeof executor.esbuildTransform !== 'function' || isStub(executor)) throw new Error('esbuild not loaded'); Type guard
function isEsbuildReady(e: unknown): e is EsbuildExecutor {
return e instanceof EsbuildExecutor && e.hasImpl?.() === true; // or probe transform with a tiny input
} Try / catch
let executor = new EsbuildExecutor();
try {
await executor.load(false);
} catch {
executor = new EsbuildExecutor(true); // force WASM
await executor.load(true);
} Prevention
- Always await the executor's load()/init before calling transform
- Do not prune optionalDependencies when installing
- Prefer WASM variant on unsupported platforms
- Re-run install after switching package managers
When it happens
Trigger: Calling esbuildTransform or esbuildFormatMessages on an EsbuildExecutor instance that was constructed but whose loadEsbuild() (native or WASM fallback) never completed or failed before assigning the real implementations.
Common situations: Installing @angular-devkit/build-angular with dependencies stripped or pruned (e.g. --omit=optional) so neither the native esbuild binary nor the WASM variant loads; unsupported platform/CPU without WASM fallback; corrupted node_modules after switching npm/yarn/pnpm; running in sandboxes that block spawning the native binary.
Related errors
- The "application" and "browser-esbuild" builders do not supp
- Only the "application" and "browser-esbuild" builders suppor
- Only the "application" and "browser-esbuild" builders suppor
- compilation is undefined.
- Terser failed for unknown reason.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/8e75fd0a6da997fe.
Report an issue: GitHub.