


You can choose Yarn then, or change it at a later time. When you run gatsby new for the first time, you’ll be prompted to choose npm or Yarn as your default package manager.

Using Yarn as your Gatsby package manager Yarn will ignore the global prefix if you’ve installed it using npx. Note: If you’ve installed Yarn with npx, you’ll need to use both the npx and yarn prefixes, e.g.: npx yarn add gatsby-cli. If you use this method, you’ll need to prefix Gatsby commands with yarn, for example, yarn gatsby develop. You can also install Gatsby locally using yarn add gatsby-cli. If you’d like to use Gatsby CLI commands such as gatsby new, install the CLI globally using the global prefix. Once installed, you can use Yarn to install the Gatsby CLI globally or locally. Read more about npm and npx in the Gatsby docs. If you install Yarn using npx, you’ll need to prefix Yarn commands with npx, e.g. Or install Yarn per project using npx: npx yarn. Use npm install yarn with the -g or -global flags to install Yarn globally. For Gatsby core development, you’ll need Yarn version 1.0.2 or later.Īlthough the Yarn documentation discourages it, you can also install Yarn using npm or npx. Choose the binary package for your operating system. You’ll need to install Yarn separately from Node.

It caches previously downloaded packages.Gatsby core uses a monorepo pattern for its code.Īs a monorepo adds projects and contributors, the number and size of its dependencies also increases. A monolithic repository, or monorepo, contains the code for many different projects in a single repository. To avoid confusion and possible conflicts with your dependencies, Gatsby recommends using npm for site development.Įngineers from Facebook, Google, Exponent, and Tilde launched Yarn in 2016 to improve package management for large-scale, monolithic repositories. Note: Most tutorials and site development examples from the Gatsby docs use npm. For Gatsby site development, you can use Yarn or npm. Gatsby theme development also uses Yarn workspaces. Gatsby core uses Yarn’s workspaces feature to manage dependencies. Contributing to Gatsby core requires Yarn. It’s an alternative to Node’s standard package manager, npm. Yarn is a package manager for the Node.js JavaScript runtime. Learn what the Yarn package manager is, how to use it, and how it fits in to the Gatsby ecosystem.
