Using Yarn with AngularΒ CLI

πŸ’‘ The updated article for Angular CLI v6+ can be found here

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.


For those of you that don’t know (I can hardly imagine that anyone reading my posts does not know this) Yarn is an alternative package manager for NPM packages with a focus on reliability and speed. It has been released in October 2016 and already gained a lot of traction and enjoys great popularity in the JavaScript community.

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.

πŸ‘‰πŸΌ Updated tutorial for Angular CLIΒ V6

To enable Yarn for Angular CLI you have to 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.

Using Yarn

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.

Happy installing!

Need help?

Need support for your Angular, Ionic, Firebase, NodeJS or TypeScript project? Looking for long-term mentorship? Feel free to book a 1-on-1 session with me on CodeMentor.
Like what you read? Give beeman 🐝 a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.