gatsbyjs/gatsby · error

Please mention both starter package and project name along…

Error message

Please mention both starter package and project name along with path(if its not in the root)

What it means

Thrown in the interactive prompts branch of init-starter when the user dismisses prompts without selecting a starter or entering a project path. The guard `if (!response.starter || !response.path.trim())` aborts before any file operations so no half-configured site is created.

Solutions

  1. Re-run `gatsby new` interactively and select a starter, then type a project name (and path if not in cwd).
  2. For non-interactive use, pass args explicitly: `gatsby new my-site gatsbyjs/gatsby-starter-default`.
  3. If scaffolding into the current directory, supply `.` only where supported, or pick an explicit subdirectory name.

Example fix

# before (cancels or leaves path blank)
gatsby new
# after (non-interactive explicit args)
gatsby new my-site gatsbyjs/gatsby-starter-blog
Defensive patterns

Strategy: validation

Validate before calling

if (!response?.starter || !String(response?.path ?? '').trim()) {
  console.error('Both starter and project path are required')
  process.exit(1)
}

Type guard

const hasPromptAnswers = (r: { starter?: string; path?: string }): boolean =>
  !!r?.starter && !!String(r?.path ?? '').trim()

Prevention

When it happens

Trigger: Running `gatsby new` with no args in a TTY, pressing Esc/Ctrl-C on the starter or path prompt, or submitting an empty path string. The prompts object (enquirer) returns undefined/empty fields and the validation fires.

Common situations: User cancels prompts by accident; non-interactive CI shell where prompts auto-resolve empty; piping empty stdin into `gatsby new`; user expects `gatsby new` to use cwd but leaves the path prompt blank.

Related errors


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

Appendix: source

Thrown at packages/gatsby-cli/src/init-starter.ts:244

      {
        type: `select`,
        name: `starter`,
        message: `What starter would you like to use?`,
        choices: [
          { title: `gatsby-starter-default`, value: `gatsby-starter-default` },
          {
            title: `gatsby-starter-hello-world`,
            value: `gatsby-starter-hello-world`,
          },
          { title: `gatsby-starter-blog`, value: `gatsby-starter-blog` },
          { title: `(Use a different starter)`, value: `different` },
        ],
        initial: 0,
      },
    ])
    // exit gracefully if responses aren't provided
    if (!response.starter || !response.path.trim()) {
      throw new Error(
        `Please mention both starter package and project name along with path(if its not in the root)`
      )
    }

    selectedOtherStarter = response.starter === `different`
    starterPath = `gatsbyjs/${response.starter}`
    rootPath = response.path
  }

  // set defaults if no root or starter has been set yet
  rootPath = rootPath || process.cwd()
  starterPath = starterPath || `gatsbyjs/gatsby-starter-default`

  return { starterPath, rootPath, selectedOtherStarter }
}

const successMessage = (path: string): void => {
  report.info(`

View on GitHub (pinned to 8b06340921)