{"record":{"id":"e3b455f1bf146d0f","repo":"serverless/serverless","slug":"esbuld-build-error","errorCode":"ESBULD_BUILD_ERROR","errorMessage":"${err.message}","messagePattern":"\\$\\{err\\.message\\}","errorType":"error_code","errorClass":"ServerlessError","httpStatus":null,"severity":"error","filePath":"packages/serverless/lib/plugins/esbuild/index.js","lineNumber":1072,"sourceCode":"      }\n\n      try {\n        await this._buildProject(\n          functionsToBuild,\n          handlerPropertyName,\n          buildProperties,\n        )\n      } catch (err) {\n        if (this.serverless.devmodeEnabled === true) {\n          return\n        }\n        // Errors this path raises deliberately (an output collision, an\n        // unusable `outExtension`) already say what to do about them; only\n        // esbuild's own failures need wrapping.\n        if (err instanceof ServerlessError) {\n          throw err\n        }\n        throw new ServerlessError(err.message, 'ESBULD_BUILD_ERROR')\n      }\n\n      if (handlerPropertyName !== 'originalHandler') {\n        this._assertAllHandlersBuilt(functionsToBuild, handlerPropertyName)\n      }\n\n      return\n    }\n\n    const outputExtension = this._outputExtension(buildProperties)\n\n    // Multiple functions can share a single handler file (e.g. one module\n    // exporting several handlers). Building each function separately would\n    // spawn concurrent esbuild.build() calls writing to the same outfile,\n    // racing on truncate+write and corrupting the output (#13716). Instead we\n    // group functions by their resolved absolute entry path and build each\n    // unique file once, applying the per-function side effects to every alias\n    // in the group afterwards.","sourceCodeStart":1054,"sourceCodeEnd":1090,"githubUrl":"https://github.com/serverless/serverless/blob/ba6ba66c01ae3cbb5f6ae458ea12e3814b815ba0/packages/serverless/lib/plugins/esbuild/index.js#L1054-L1090","documentation":"Generic wrapper for esbuild's own build failures: when the build step throws and the error is not already a ServerlessError raised deliberately by the plugin (output collision, outExtension mismatch, etc.), it is re-wrapped with code ESBULD_BUILD_ERROR keeping the original message. Read err.message — it is esbuild's underlying diagnostic.","triggerScenarios":"Any esbuild compilation failure during _buildProject: syntax errors, unresolved imports, invalid loader/plugin errors, tsconfig problems — anything esbuild itself rejects.","commonSituations":"TypeScript type/syntax errors, importing a missing module, a bad tsconfig path, unsupported syntax for the target runtime.","solutions":["Read err.message for esbuild's actual diagnostic and fix the source/import it names","Run esbuild or tsc directly on the file to reproduce the error faster","Verify tsconfig and build.esbuild options (target, loaders, plugins) are valid","If a plugin you added throws, fix or remove that plugin"],"exampleFix":"// before\nimport { foo } from './nonexistent'\n// after\nimport { foo } from './utils'","handlingStrategy":"try-catch","validationCode":"// pre-check: compile the entry points with esbuild directly to surface diagnostics early\nimport { build } from 'esbuild'\nawait build({ entryPoints: ['src/handler.ts'], bundle: true, write: false, logLevel: 'silent' })","typeGuard":null,"tryCatchPattern":"try {\n  await deploy()\n} catch (e) {\n  if (e.code === 'ESBULD_BUILD_ERROR') {\n    // e.message is esbuild's own diagnostic; surface it verbatim\n    console.error('esbuild failed:', e.message)\n  }\n  throw e\n}","preventionTips":["Run tsc --noEmit or esbuild locally before deploying","Keep imports valid and committed; avoid missing modules in CI","Pin esbuild config (target, loaders, tsconfig) and validate after changes","Read err.message first — it is the raw esbuild diagnostic, not a generic failure"],"tags":["esbuild","build","typescript"],"backgroundTag":"upstream-api-error","analyzedSha":"ba6ba66c01ae3cbb5f6ae458ea12e3814b815ba0","analyzedAt":"2026-09-13T23:08:04.935Z","contentChangedAt":"2026-09-13T23:08:04.935Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}