{"record":{"id":"522ec9032b6e411e","repo":"mastra-ai/mastra","slug":"could-not-determine-project-name-from-package-json-522ec9","errorCode":null,"errorMessage":"Could not determine project name from package.json. Use --project to specify one.","messagePattern":"Could not determine project name from package\\.json\\. Use --project to specify one\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/studio/deploy.ts","lineNumber":358,"sourceCode":"      ],\n    });\n\n    if (p.isCancel(selected)) {\n      p.cancel('Deploy cancelled.');\n      process.exit(0);\n    }\n\n    if (selected !== CREATE_NEW) {\n      const match = projects.find(proj => proj.id === selected)!;\n      return { existing: true, projectId: match.id, projectName: match.name, projectSlug: match.slug ?? match.name };\n    }\n    // fall through to create-new flow\n  }\n\n  // 4. No existing project (or user chose \"Create new\") — return the name so caller can create after confirmation.\n  const name = defaultName;\n  if (!name) {\n    throw new Error('Could not determine project name from package.json. Use --project to specify one.');\n  }\n\n  return { existing: false, projectName: name };\n}\n\n/* ------------------------------------------------------------------ */\n/*  Main deploy action                                                */\n/* ------------------------------------------------------------------ */\n\ntype StudioDeployOptions = {\n  org?: string;\n  project?: string;\n  yes?: boolean;\n  config?: string;\n  skipBuild?: boolean;\n  skipPreflight?: boolean;\n  debug?: boolean;\n  envFile?: string;","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/cli/src/commands/studio/deploy.ts#L340-L376","documentation":"When the deploy flow decides a new project must be created, it derives the project name from the local package.json `name` field. If that value is missing (no name, or no readable package.json), the command cannot name the project and throws, telling you to supply one via --project.","triggerScenarios":"Running `mastra studio deploy` in a directory without package.json, or with a package.json lacking a `name` field, when no existing project was matched/selected (create-new path reached).","commonSituations":"Deploying from a scratch directory or a package-less workspace; a monorepo root package.json with no name; typos like \"naem\" in package.json; deploying an app initialized outside npm/pnpm conventions.","solutions":["Pass the name explicitly: `mastra studio deploy --project my-project-name`","Add a `name` field to package.json in the deploy directory","Run the command from the directory containing the correct package.json","If a project already exists, target it with --project <id-or-slug> to skip the create-new flow"],"exampleFix":"// before (package.json)\n{ \"version\": \"1.0.0\" }\n// Error: Could not determine project name from package.json.\n// after\n{ \"name\": \"my-mastra-app\", \"version\": \"1.0.0\" }","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs';\nconst pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));\nif (typeof pkg.name !== 'string' || pkg.name.length === 0) {\n  throw new Error('package.json has no name; pass --project <name> to deploy.');\n}","typeGuard":"function hasProjectName(pkg: unknown): pkg is { name: string } {\n  return typeof pkg === 'object' && pkg !== null && 'name' in pkg && typeof (pkg as { name?: unknown }).name === 'string' && (pkg as { name: string }).name.length > 0;\n}","tryCatchPattern":"try {\n  await studioDeploy();\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Could not determine project name from package.json')) {\n    console.error('Add a name to package.json or pass --project <name>.');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Always set a `name` in package.json for deployable packages","Run deploys from the package directory, not the repo root","In monorepos, point deploy at the specific workspace package with a name","Add a CI check that package.json parses and has a non-empty name before deploy"],"tags":["cli","package-json","configuration"],"backgroundTag":"missing-package-json-name","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}