{"record":{"id":"8e75fd0a6da997fe","repo":"angular/angular-cli","slug":"esbuild-implementation-missing","errorCode":null,"errorMessage":"esbuild implementation missing","messagePattern":"esbuild implementation missing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/build_angular/src/tools/webpack/plugins/esbuild-executor.ts","lineNumber":38,"sourceCode":" * At first use of esbuild, a supportability test will be automatically performed and the\n * WASM-variant will be used if needed by the platform.\n */\nexport class EsbuildExecutor\n  implements Pick<typeof import('esbuild'), 'transform' | 'formatMessages'>\n{\n  private esbuildTransform: this['transform'];\n  private esbuildFormatMessages: this['formatMessages'];\n  private initialized = false;\n\n  /**\n   * Constructs an instance of the `EsbuildExecutor` class.\n   *\n   * @param alwaysUseWasm If true, the WASM-variant will be preferred and no support test will be\n   * performed; if false (default), the native variant will be preferred.\n   */\n  constructor(private alwaysUseWasm = false) {\n    this.esbuildTransform = this.esbuildFormatMessages = () => {\n      throw new Error('esbuild implementation missing');\n    };\n  }\n\n  /**\n   * Determines whether the native variant of esbuild can be used on the current platform.\n   *\n   * @returns A promise which resolves to `true`, if the native variant of esbuild is support or `false`, if the WASM variant is required.\n   */\n  static async hasNativeSupport(): Promise<boolean> {\n    // Try to use native variant to ensure it is functional for the platform.\n    try {\n      const { formatMessages } = await import('esbuild');\n      await formatMessages([], { kind: 'error' });\n\n      return true;\n    } catch {\n      return false;\n    }","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/tools/webpack/plugins/esbuild-executor.ts#L20-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before (package.json)\n{\"scripts\": {\"install\": \"npm install --omit=optional\"}}\n// after\n{\"scripts\": {\"install\": \"npm install\"}}","handlingStrategy":"fallback","validationCode":"const executor = new EsbuildExecutor(wasm);\nawait executor.load(true).catch(() => new EsbuildExecutor(true).load(true));\nif (typeof executor.esbuildTransform !== 'function' || isStub(executor)) throw new Error('esbuild not loaded');","typeGuard":"function isEsbuildReady(e: unknown): e is EsbuildExecutor {\n  return e instanceof EsbuildExecutor && e.hasImpl?.() === true; // or probe transform with a tiny input\n}","tryCatchPattern":"let executor = new EsbuildExecutor();\ntry {\n  await executor.load(false);\n} catch {\n  executor = new EsbuildExecutor(true); // force WASM\n  await executor.load(true);\n}","preventionTips":["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"],"tags":["esbuild","webpack","angular-cli","initialization"],"backgroundTag":"esbuild-implementation-missing","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}