Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Yarn Create & Yarn 1.0

Posted May 12, 2017 by Maël Nison

Last year was a great time for Javascript newcomers! A lot of starter-kit projects were published, refined, and some of them eventually went on to offer command line tools dedicated to make project creation easier. One such example is create-react-app, but most frameworks have their own tools, with various flavors and syntaxes.

Despite these tools, one problem remains: Users still need to know how to use their package managers before being able to start a new project. They need to know what’s the difference between global packages and local packages, and how to make sure that the binaries are available from the shell, which can sometimes cause subtle issues. Further, because these globally installed tools need to be manually updated, most projects maintain a small cli wrapper that downloads the latest version of the tool itself. Fortunately, we’re in a position where we can help with this to make building new applications more cohesive:

yarn create <pkg-name>

With yarn create, you can start building apps with many of the existing projects:

  • yarn create react-app my-app
  • yarn create react-native-app my-app
  • yarn create next-app my-app

When ran, the create command will automatically install or update the requested package, prefixing its name with create-. Running yarn create react-app will start by doing the same thing as yarn global add create-react-app. Then, once the package installed, Yarn will run the executable located in the bin field of the newly installed package’s package.json, forwarding to it any remaining command line argument.

It is important to us to keep the feature small and extensible. Yarn should be a lightweight tool and yarn create is no exception: An immediate implication is that the create command is a completely agnostic tool: we make no assumption regarding what you want to create, and delegate all the behavior to the create-* packages! It is our hope that the community will come up with creative way to use this tool. Creating apps is but only one thing! Feel free to make packages that create tests, readmes, changelogs or anything else you want!

Note: The create- prefix is inserted right before the package name. So, for example, if you run yarn create @ng/app, it will install the @ng/create-app package, then run it.

Other Improvements

yarn create is but one of the many things we have been working on over the last couple of weeks. Thanks to numerous pull requests from many open source contributors, the recent releases also ship with the following features & improvements:

  • The offline mirror does not require changes to the yarn lockfile any longer (#2970)
  • Command-line arguments and environment variables can now be set in the yarnrc file (#3033, #3218)
  • Prepare & prepublish-only lifecycle hooks are now implemented (#3004)
  • The offline mirror can be pruned if used by a single one of your projects (#2836)
  • Various improvements for yarn pack (#3175, #3092)

The list of all improvements and bugfixes over the last couple of months can be found in our releases section on GitHub. We would specifically like to thank a team from the Delft University of Technology: Tim van der Lippe, Chris Langhout, Gijs Weterings and Chak Shun Yu. The four of them did a fantastic analysis of the Yarn project and sent pull requests to improve it in many areas. They also pointed out gaps in our test coverage, which our new core contributor Simon Vocella has been working on improving.

Planning for Yarn 1.0

Yarn has made substantial improvements since its initial release 7 months ago and the project recently surpassed 1,000 Pull Requests. Currently, we are planning for the 1.0 release of Yarn which is scheduled for this summer and will come with stability improvements, new features and performance wins. To hear more about Yarn’s present and future, please watch Konstantin’s talk about Building High-Quality JavaScript Tools.

We thank each and every one of you for your help to make this project great. If you’d like to contribute to Yarn, please don’t hesitate to reach out to us on GitHub or on Discord.