# gatsby-cli

> Gatsby command-line interface for creating new sites and running Gatsby commands

Latest version **5.16.0** (published 2026-01-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install gatsby-cli
pnpm add gatsby-cli
yarn add gatsby-cli
bun add gatsby-cli
```

Provides the command `gatsby`.

## Health

**Score 60/100 (C)** — status: stable.

Positive: no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 5.16.0 |
| Published | 2026-01-26 |
| First published | 2017-08-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18.0.0 <26 |
| Dependencies | 40 |
| Unpacked size | 721.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 55943 |
| Author | Kyle Mathews |
| Maintainers | pieh, kathmbeck, serhalp-netlify, mlgualtieri-gatsby, kylemathews, freiksenet, dschau, monastic.panic, m-allanson, moocar |
| Keywords | gatsby |

## Links

- npm: https://www.npmjs.com/package/gatsby-cli
- Repository: https://github.com/gatsbyjs/gatsby
- Homepage: https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-cli#readme
- Issues: https://github.com/gatsbyjs/gatsby/issues
- npm.io page: https://npm.io/package/gatsby-cli

## Dependencies (40)

- [joi](https://npm.io/package/joi.md) ^17.9.2
- [boxen](https://npm.io/package/boxen.md) ^5.1.2
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [execa](https://npm.io/package/execa.md) ^5.1.1
- [redux](https://npm.io/package/redux.md) 4.2.1
- [yargs](https://npm.io/package/yargs.md) ^15.4.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [semver](https://npm.io/package/semver.md) ^7.5.3
- [envinfo](https://npm.io/package/envinfo.md) ^7.10.0
- [prompts](https://npm.io/package/prompts.md) ^2.4.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.2.0
- [progress](https://npm.io/package/progress.md) ^2.0.3
- [yurnalist](https://npm.io/package/yurnalist.md) ^2.1.0
- [better-opn](https://npm.io/package/better-opn.md) ^2.1.1
- [clipboardy](https://npm.io/package/clipboardy.md) ^4.0.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.11
- [strip-ansi](https://npm.io/package/strip-ansi.md) ^6.0.1
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.20.12
- [common-tags](https://npm.io/package/common-tags.md) ^1.8.2
- [opentracing](https://npm.io/package/opentracing.md) ^0.14.7
- [resolve-cwd](https://npm.io/package/resolve-cwd.md) ^3.0.0
- [signal-exit](https://npm.io/package/signal-exit.md) ^3.0.7
- [stack-trace](https://npm.io/package/stack-trace.md) ^0.0.10
- [@babel/types](https://npm.io/package/@babel/types.md) ^7.20.7
- [pretty-error](https://npm.io/package/pretty-error.md) ^2.1.2
- [create-gatsby](https://npm.io/package/create-gatsby.md) ^3.16.0
- [is-valid-path](https://npm.io/package/is-valid-path.md) ^0.1.1
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.20.13
- [convert-hrtime](https://npm.io/package/convert-hrtime.md) ^3.0.0
- [@babel/template](https://npm.io/package/@babel/template.md) ^7.20.7
- [hosted-git-info](https://npm.io/package/hosted-git-info.md) ^3.0.8
- [@babel/generator](https://npm.io/package/@babel/generator.md) ^7.20.14
- [fs-exists-cached](https://npm.io/package/fs-exists-cached.md) ^1.0.0
- [@babel/code-frame](https://npm.io/package/@babel/code-frame.md) ^7.18.6
- [gatsby-core-utils](https://npm.io/package/gatsby-core-utils.md) ^4.16.0
- [@types/common-tags](https://npm.io/package/@types/common-tags.md) ^1.8.1
- [yoga-layout-prebuilt](https://npm.io/package/yoga-layout-prebuilt.md) ^1.10.0
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.18.6
- [@jridgewell/trace-mapping](https://npm.io/package/@jridgewell/trace-mapping.md) ^0.3.18
- [@babel/helper-plugin-utils](https://npm.io/package/@babel/helper-plugin-utils.md) ^7.20.2

## Recent versions

- 5.16.0 (latest) — 2026-01-26
- 5.17.0-next.1 (next) — 2025-12-22
- 5.17.0-react19.1 (react19) — 2025-11-26
- 5.13.0-alpha-alt-image-cdn.44 (alt-image-cdn) — 2023-11-03
- 5.10.0-alpha-adapters.165 (alpha-adapters) — 2023-07-14
- 5.9.0-alpha-cg-tailwind.23 (alpha-cg-tailwind) — 2023-05-09
- 5.9.0-image-cdn-configurable.4 (image-cdn-configurable) — 2023-04-11
- 5.8.0-alpha-react-profiling-env.8 (alpha-react-profiling-env) — 2023-03-17
- 3.15.0 (latest-v3) — 2022-12-07
- 4.25.0 (latest-v4) — 2022-12-07
- 5.0.0-alpha-drupal-proxyurl.11 (drupal-proxyurl) — 2022-11-22
- 4.24.1-alpha-wordpress-image-err.27 (wordpress-image-err) — 2022-11-09
- 4.14.0-alpha-transformer-json.26 (alpha-transformer-json) — 2022-10-12
- 5.0.0-alpha-v5.d20221012t101120.57 (alpha-v5) — 2022-10-12
- 4.25.0-alpha-preview-slices.d20221011t181843.56 (preview-slices) — 2022-10-11
- … 1047 more at https://npm.io/package/gatsby-cli/versions

## README

# gatsby-cli

The Gatsby command line interface (CLI) is the main tool you use to initialize, build and develop Gatsby sites.

## How to use gatsby-cli

To use the Gatsby CLI you must either:

- Install it globally with `npm install -g gatsby-cli`, where you execute commands with the syntax `gatsby new`, or
- Run commands directly with [`npx`](https://nodejs.dev/en/learn/the-npx-nodejs-package-runner/), where you execute commands with the syntax `npx gatsby new`

Useful Gatsby CLI commands are also pre-defined in [starters](https://gatsbyjs.com/docs/starters/) as [run scripts](https://gatsbyjs.com/docs/glossary#run-script).

## CLI Commands

All the following documentation is available in the tool by running `gatsby --help`.

Available commands are:

- [new](#new)
- [develop](#develop)
- [build](#build)
- [serve](#serve)
- [clean](#clean)
- [info](#info)
- [repl](#repl)

### `new`

Runs an interactive shell with a prompt that helps you set up a [CMS](https://gatsbyjs.com/docs/glossary#cms), styling system and plugins if you wish.

To create a new site with the prompt, execute:

```shell
gatsby new
```

You can also skip the prompt and clone a starter directly from GitHub. For example, to clone a new [gatsby-starter-blog](https://github.com/gatsbyjs/gatsby-starter-blog), execute:

```shell
gatsby new my-new-blog https://github.com/gatsbyjs/gatsby-starter-blog
```

The first argument (e.g. `my-new-blog`) is the name of your site, and the second argument is the GitHub URL of the starter you want to clone.

> Note: The site name should only consist of letters and numbers. If you specify a `.`, `./` or a `<space>` in the name, `gatsby new` will throw an error.

### `develop`

Compiles and serves a development build of your site that reflects your source code changes in the browser in real time. Should be run from the root of your project.

```shell
gatsby develop
```

Options include:

| Option          | Description                                     |
| --------------- | ----------------------------------------------- |
| `-H`, `--host`  | Set host. Defaults to `localhost`               |
| `-p`, `--port`  | Set port. Defaults to `env.PORT` or `8000`      |
| `-o`, `--open`  | Open the site in your (default) browser for you |
| `-S`, `--https` | Use HTTPS                                       |
| `--inspect`     | Opens a port for debugging                      |

To set up HTTPS, follow the [Local HTTPS guide](https://gatsbyjs.com/docs/local-https/).

To include a URL you can access from other devices on the same network, execute:

```shell
gatsby develop -H 0.0.0.0
```

You will see this output:

```shell
You can now view gatsbyjs.com in the browser.
⠀
  Local:            http://0.0.0.0:8000/
  On Your Network:  http://192.168.0.212:8000/ // highlight-line
```

You can use the "On Your Network" URL to access your site within your network.

### `build`

Compiles your site for production so it can be deployed. Should be run from the root of your project.

```shell
gatsby build
```

Options include:

| Option                       | Description                                                                                                                                                      |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--prefix-paths`             | Build site with link paths prefixed (set `pathPrefix` in your config)                                                                                            |
| `--no-uglify`                | Build site without uglifying JS bundles (for debugging)                                                                                                          |
| `--profile`                  | Build site with react profiling. See [Profiling Site Performance with React Profiler](https://gatsbyjs.com/docs/profiling-site-performance-with-react-profiler/) |
| `--open-tracing-config-file` | Tracer configuration file (OpenTracing compatible). See [Performance Tracing](https://gatsbyjs.com/docs/performance-tracing/)                                    |
| `--graphql-tracing`          | Trace (see above) every graphql resolver, may have performance implications.                                                                                     |
| `--no-color`, `--no-colors`  | Disables colored terminal output                                                                                                                                 |

In addition to these build options, there are some optional [build environment variables](https://gatsbyjs.com/docs/how-to/local-development/environment-variables/#build-variables) for more advanced configurations that can adjust how a build runs. For example, setting `CI=true` as an environment variable will tailor output for [dumb terminals](https://en.wikipedia.org/wiki/Computer_terminal#Dumb_terminals).

### `serve`

Serves the production build of your site for testing prior to deployment. Should be run from the root of your project.

```shell
gatsby serve
```

Options include:

| Option           | Description                                                                                    |
| ---------------- | ---------------------------------------------------------------------------------------------- |
| `-H`, `--host`   | Set host. Defaults to `localhost`                                                              |
| `-p`, `--port`   | Set port. Defaults to `9000`                                                                   |
| `-o`, `--open`   | Open the site in your default browser for you                                                  |
| `--prefix-paths` | Serve site with link paths prefixed (if built with `pathPrefix` in your `gatsby-config` file). |

### `info`

Show helpful environment information which is required in bug reports. Should be run from the root of your project.

```shell
gatsby info
```

Options include:

| Option              | Description                                    |
| ------------------- | ---------------------------------------------- |
| `-C`, `--clipboard` | Copy environment information to your clipboard |

### `clean`

Delete the `.cache` and `public` directories. Should be run from the root of your project.

```shell
gatsby clean
```

This is useful as a last resort when your local project seems to have issues or content does not seem to be refreshing. Issues this may fix commonly include:

- Stale data, e.g. this file/resource/etc. isn't appearing
- GraphQL error, e.g. this GraphQL resource should be present but is not
- Dependency issues, e.g. invalid version, cryptic errors in console, etc.
- Plugin issues, e.g. developing a local plugin and changes don't seem to be taking effect

### `repl`

Open a Node.js REPL (interactive shell) with context of your Gatsby environment. Should be run from the root of your project.

```shell
gatsby repl
```

Gatsby will prompt you to type in commands and explore. When it shows this: `gatsby >`, you can type in one of these commands to see their values in real time:

- `babelrc`
- `components`
- `dataPaths`
- `getNodes()`
- `nodes`
- `pages`
- `schema`
- `siteConfig`
- `staticQueries`

To exit the REPL:

- Press `Ctrl+C` or `Ctrl+D` twice, or
- Type `.exit` and press `Enter`

When combined with the [GraphQL explorer](https://gatsbyjs.com/docs/how-to/querying-data/running-queries-with-graphiql/), these REPL commands could be very helpful for understanding your Gatsby site's data.

---
_Source: https://npm.io/package/gatsby-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
