Package Managers
Switching from NPM to Yarn
While you may be familiar with npm, or even use it as your package manager of choice, it is not the recommended package manager for this project. This is because Yarn is faster, more reliable, and more extensible than npm. If you are not familiar with Yarn, you can read more about it here.
To download Yarn using npm, run the following command:
npm install -g yarnThis will install Yarn Classic/v1 globally on your machine.
Upgrading to Yarn 3
Why Yarn 3
Yarn 3 includes a host of benefits over Yarn Classic/v1, including:
Even faster installs
More verbose & readable output
Yarn versionis stored directly in the repo to keep everyone on the same versionYarn pluginscan be added to extend the functionality ofYarnPnP(Plug and Play) mode can be used to improve performance and stability (if supported by your project)Helpful, new commands like
yarn dedupe,yarn info, & more
Yarn does not use
PnPby default. If you would like to usePnP, you can read more about it here.
Read more about the differences between
Yarn Classic/v1andYarn 3here.
Upgrading
To upgrade to Yarn 3 from Yarn Classic/v1, run the following command:
yarn set version berry
yarn installYarn Plugins
Now, you can start getting plugins to extend the functionality of Yarn 3.
Yarn-Typescript Plugin
yarn plugin import typescriptThis will install the Yarn-TypeScript plugin, which automatically adds @types/ packages into your dependencies when you add a package that doesn't include its own types
Interactive-Tools
yarn plugin import interactive-toolsThis will install the Interactive-Tools plugin, which includes the yarn dedupe & yarn upgrade-interactive commands. These commands will help you to remove duplicate packages from your node_modules folder, and upgrade your dependencies to the latest versions.
Last updated
Was this helpful?