gatsbyjs/gatsby · error
11613
11613
Error message
11613
What it means
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.
Source
Thrown at packages/gatsby-cli/src/init-starter.ts:325
context: {
rootPath,
},
})
return
}
if (!isValid(rootPath)) {
report.panic({
id: `11612`,
context: {
path: sysPath.resolve(rootPath),
},
})
return
}
if (existsSync(sysPath.join(rootPath, `package.json`))) {
report.panic({
id: `11613`,
context: {
rootPath,
},
})
return
}
const hostedInfo = hostedGitInfo.fromUrl(starterPath)
if (hostedInfo) {
await clone(hostedInfo, rootPath)
} else {
await copy(starterPath, rootPath)
}
const sitePath = sysPath.resolve(rootPath)
View on GitHub (pinned to 8b06340921)
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.
Example fix
# before: target already has package.json gatsby new . # after: use a new directory, or remove the existing file rm package.json gatsby new .
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs'); const path = require('path')
function assertEmpty(dir) {
if (fs.existsSync(path.join(dir, 'package.json'))) throw new Error('Target already has package.json')
} Prevention
- 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.
When it happens
Trigger: Running `gatsby new ./existing-dir` (or `gatsby new .`) where the directory already has a `package.json`. The scaffolder protects the existing project.
Common situations: Re-running `gatsby new` in a folder already bootstrapped; pointing at a monorepo package that already exists; accidental overwrite attempt.
Related errors
- starter ${starterPath} doesn't exist
- gatsby <${command}> can only be run for a gatsby site. Eithe
- 11610
- 11611
- 11612
AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13).
Data as JSON: /api/errors/ca25e638d51af2ea.
Report an issue: GitHub.