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

  1. Choose a fresh directory name that has no `package.json`: `gatsby new my-new-site`.
  2. If you intend to reset an existing project, delete or move its `package.json` first (and back it up).
  3. 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

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


AI-assisted analysis of gatsbyjs/gatsby@8b06340921 (2026-08-13). Data as JSON: /api/errors/ca25e638d51af2ea. Report an issue: GitHub.