Yarn package manager
Yarn was developed by Facebook to address some of the early performance and dependency issues introduced by npm, offering an alternative.
Initially, many developers switched from npm to Yarn due to its superior speed and reliability. Over time, npm made improvements, adopting several features from Yarn. Both now utilize lock files for dependencies, offer efficient caching, and boast quick package installation. These days, the choice between npm and Yarn is often a matter of personal preference.
Like npm, Yarn is primarily used in web development to manage dependencies for JavaScript and Node.js projects. Yarn helps developers easily install, update, and manage libraries and packages that their projects depend on.
Yarn has its own codebase but still uses the npm registry for packages. The main difference between Yarn and npm lies in how packages are cached, used, and maintained.
To determine if a project is using Yarn, check the project directory for a locked yarn.lock file. If it's present, Yarn is managing packages and dependencies. Conversely, if you see a package-lock.json file, it means you should use npm for package management.
Currently, there are 3 versions of Yarn Yarn V1, Yarn V2 Yarn V3. Most people opt for Yarn 2 as an alternative to npm. The question arises: What distinguishes Yarn v1 from Yarn v2? Yarn v2, also known as Berry, represents a completely new approach to package management, eliminating the need for the node_modules folder in Node.js projects.
The main issue with previous versions of Yarn and npm was their reliance on the node_modules folder. This folder simply contained copies of all installed packages for each project, and improving its speed was challenging due to the nature of copying.
Yarn 3, or Berry, aims to resolve this issue by eliminating the dependency on the node_modules folder. Instead, Yarn 2 employs a feature called "plug-and-play." However, it's important to note that not all technologies and ecosystems fully support Yarn 2.