npm is the default package manager for Node.js. Facebook has long been developing an alternative package management solution called Yarn . Yarn seems to be slowly disappearing from the GitHub readmes as the default solution and the stats on the official site show that only a fraction of package installations are carried out with Yarn. Nevertheless, it is worth looking outside the box.
Yarn is fully compatible with existing package.json files, so you can easily use both solutions in existing projects. The commands for the two solutions differ only slightly. Below is a comparison of the most important commands.:
| Description | npm | Yarn |
| Initialize | npm init | yarn init |
| Update | npm install -g npm | yarn self-update |
| Installing the package | npm install --save [name] | yarn add [name] |
| Installing the package | npm install --save-dev [name] | yarn add --dev [name] |
| Install package globally | npm install -g [name] | yarn global add [name] |
| Install all packages | npm install | yarn install |
| Update all packages | npm update | yarn upgrade |
| Uninstalling a package | npm remove [name] | yarn remove [name] |
Yarn started with the goal of solving some of npm's pain points. The most obvious difference is the higher performance: through incremental installations, multithreading and the latest killer feature Plug'n'Play (PNP), performance increases dramatically. Plug'n'Play rejects the idea of a project-based node_modules folder, which can often grow to astronomical heights in the number of files. You can find out more about this in the official Plug'n'Play white paper . We install eslint once with npm and then with yarn with the cache warmed up in each case to make the difference in speed clear (6x!):

