My second most popular story here on Medium was Using Yarn with Angular CLI. Time for an update because in the new release of Angular CLI v6+ a lot of things have changed. What did not change is that you can still configure your preferred package manager.
Configure the package manager
yarn for Angular CLI you have to run the following command:
ng config -g cli.packageManager yarn
Additionally, Angular CLI has support for cnpm, a package manager that works behind the Chinese firewall. As expected, you can activate it with this command:
ng config -g cli.packageManager cnpm
If at any point you want to revert back to
npm run this:
ng config -g cli.packageManager npm
Global Angular CLI config file
Because we passed in the
-g flag in our
ng config command, the changes are stored in the global Angular CLI configuration. If for whatever reason you like to change the package manager for the current project only, you can simply leave out the
The global configuration file is stored in
<YOUR_HOMEDIR>/.angular-config.json and in the snippet below you can see how the settings are stored.
$ cat ~/.angular-config.json
Thanks for reading my article, I hope it was useful. Shares and claps are always appreciated! Feel free to reach out and follow me on Twitter or leave a comment below! ✌🏼🐝
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.