Using Yarn with Angular CLI
Today was a good day for Angular CLI, a new beta-version (.31) got released and it came with quite a few nice features. To name a few:
- Support for generating projects with Angular v4 (more on this soon!)
- Support for TypeScript 2.1
- Support for Yarn
The full list of changes in Angular CLI can be found here.
Angular CLI & Yarn
Angular CLI depends on the package manager when running
ng new, the command used to create a new project. While this is not something that you do all the time when working on a project, it might make quite the difference when you create new projects often to test or play around.
To enable Yarn for Angular CLI you have ti run the following command:
ng set --global packageManager=yarn
To later revert it back to using npm use this:
ng set --global packageManager=npm
Also added in the same change is support for cnpm, the npm alternative that works behind the Chinese firewall. Simply replace the value of the
packageManager parameter in the command above to get it.
It might take some time to get
npm install out of your muscle memory. To read up on how to work with Yarn you can refer to the documentation on the website, or ask our friend Google.