Posted May 12, 2017 by Maël Nison
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>
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
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!
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.
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
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.