npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gatsby-cli

v5.13.3

Published

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

Downloads

1,415,142

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, where you execute commands with the syntax npx gatsby new

Useful Gatsby CLI commands are also pre-defined in starters as run scripts.

CLI Commands

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

Available commands are:

new

Runs an interactive shell with a prompt that helps you set up a CMS, styling system and plugins if you wish.

To create a new site with the prompt, execute:

gatsby new

You can also skip the prompt and clone a starter directly from GitHub. For example, to clone a new gatsby-starter-blog, execute:

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.

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.

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

gatsby develop -H 0.0.0.0

You will see this output:

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.

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 | | --open-tracing-config-file | Tracer configuration file (OpenTracing compatible). See 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 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.

serve

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

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.

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.

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.

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, these REPL commands could be very helpful for understanding your Gatsby site's data.