{"record":{"id":"2a0cd983f5ff3199","repo":"mastra-ai/mastra","slug":"no-index-mjs-found-in-dir-did-the-build-suc","errorCode":null,"errorMessage":"No index.mjs found in \"${dir}\" — did the build succeed?","messagePattern":"No index\\.mjs found in \"(.+?)\" — did the build succeed\\?","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deployers/sandbox/src/engine.ts","lineNumber":60,"sourceCode":" * contract (`executeCommand` + `networking`, with `writeFiles` / `processes`\n * as fast paths).\n */\nexport async function deployToSandbox(options: DeployToSandboxOptions): Promise<SandboxDeployment> {\n  const {\n    sandbox,\n    dir,\n    port = DEFAULT_PORT,\n    env = {},\n    studio = false,\n    healthCheckPath = '/api',\n    healthCheckTimeoutMs = 60_000,\n    healthCheckIntervalMs = 1_000,\n    installCommand = 'npm install --omit=dev',\n    logger = noopLogger,\n  } = options;\n\n  if (!existsSync(join(dir, 'index.mjs'))) {\n    throw new Error(`No index.mjs found in \"${dir}\" — did the build succeed?`);\n  }\n\n  // 1. Start (providers handle create-or-resume by identity, e.g. sandbox name).\n  logger.info(`Starting ${sandbox.provider} sandbox...`);\n  await sandbox.start?.();\n\n  if (!supportsNetworking(sandbox)) {\n    throw new Error(\n      `Sandbox provider \"${sandbox.provider}\" does not support networking (public port URLs), ` +\n        `which is required for sandbox deploys.`,\n    );\n  }\n  if (!sandbox.executeCommand) {\n    throw new Error(\n      `Sandbox provider \"${sandbox.provider}\" does not support executeCommand, which is required for sandbox deploys.`,\n    );\n  }\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/deployers/sandbox/src/engine.ts#L42-L78","documentation":"deployToSandbox verifies that the build output directory contains index.mjs (the Mastra server bundle entry) before doing anything else. If it's missing, the build output is assumed to be incomplete or absent, so the deploy aborts early.","triggerScenarios":"Calling deployToSandbox with a `dir` that was never built, points at the wrong directory, or where the build emitted a different entry filename.","commonSituations":"Forgetting to run the build before deploying; running the deployer from the wrong working directory so `dir` resolves elsewhere; custom bundler output naming (e.g. index.js instead of index.mjs); a failed build that still exited 0.","solutions":["Run the build (`mastra build` or equivalent) before deploying","Check that dir/index.mjs exists locally before deploying (ls <dir>)","If using a custom build, configure output filename to index.mjs or point dir at the real output directory","Fix any silent build failures reported earlier in CI logs"],"exampleFix":"// before\nnpx mastra deploy --dir ./output   # never built\n// after\nnpx mastra build && npx mastra deploy --dir ./output","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nif (!existsSync(join(dir, 'index.mjs'))) {\n  throw new Error(`build output missing: run the build before deploying to ${dir}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always build before deploy (CI: build step precedes deploy step)","Verify the output directory path with ls before deploying","Configure custom bundlers to emit index.mjs"],"tags":["build","deployment","missing-file","sandbox"],"backgroundTag":"build-artifact-missing","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}