{"record":{"id":"ca25e638d51af2ea","repo":"gatsbyjs/gatsby","slug":"11613","errorCode":"11613","errorMessage":"11613","messagePattern":"11613","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-cli/src/init-starter.ts","lineNumber":325,"sourceCode":"      context: {\n        rootPath,\n      },\n    })\n    return\n  }\n\n  if (!isValid(rootPath)) {\n    report.panic({\n      id: `11612`,\n      context: {\n        path: sysPath.resolve(rootPath),\n      },\n    })\n    return\n  }\n\n  if (existsSync(sysPath.join(rootPath, `package.json`))) {\n    report.panic({\n      id: `11613`,\n      context: {\n        rootPath,\n      },\n    })\n    return\n  }\n\n  const hostedInfo = hostedGitInfo.fromUrl(starterPath)\n\n  if (hostedInfo) {\n    await clone(hostedInfo, rootPath)\n  } else {\n    await copy(starterPath, rootPath)\n  }\n\n  const sitePath = sysPath.resolve(rootPath)\n","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-cli/src/init-starter.ts#L307-L343","documentation":"Structured error 11613 from `gatsby new`. Fires when `existsSync(path.join(rootPath, 'package.json'))` is true, i.e. the target directory already contains a `package.json`. `gatsby new` refuses to overwrite an existing project to avoid clobbering it.","triggerScenarios":"Running `gatsby new ./existing-dir` (or `gatsby new .`) where the directory already has a `package.json`. The scaffolder protects the existing project.","commonSituations":"Re-running `gatsby new` in a folder already bootstrapped; pointing at a monorepo package that already exists; accidental overwrite attempt.","solutions":["Choose a fresh directory name that has no `package.json`: `gatsby new my-new-site`.","If you intend to reset an existing project, delete or move its `package.json` first (and back it up).","For re-scaffolding, remove the offending `package.json` and rerun, or use a different path."],"exampleFix":"# before: target already has package.json\ngatsby new .\n\n# after: use a new directory, or remove the existing file\nrm package.json\ngatsby new .","handlingStrategy":"validation","validationCode":"const fs = require('fs'); const path = require('path')\nfunction assertEmpty(dir) {\n  if (fs.existsSync(path.join(dir, 'package.json'))) throw new Error('Target already has package.json')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Point `gatsby new` at a directory without a `package.json`.","Back up and remove an existing `package.json` before re-scaffolding.","Use a fresh directory name for each new project."],"tags":["cli","gatsby-new","filesystem","safety","package-json"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}