It has a registry for both public and private use which offers packages distribution for your own team or open-source modules for the community.
it is the first package manager that comes out alongside the Nodejs ecosystem for managing projects, installing packages and allowing easy and reliable project deployment and collaboration.
Yarn is a package manager for your code. It came to correct NPM’s cons and misfalls, developed by the team at Facebook mainly for fixing incompatible versions on NPM 3 using a lock file.
Yarn uses Npm’s registry to install packages. It also allows package installation from both GitHub repos or local repos alongside the Npm's registry.
a lot of developers moved to yarn in early days due to the misfalls Npm had in the past which is mainly about collaboration and deployment where moving a project from one machine to another broke the app because of the wrong dependencies version Npm did install since NPM v3 and earlier didn't have a lock file for locking current project's dependencies versions and that's one the main reasons Yarn had been created by the team at facebook to correct those issues Npm had in the past.
Npm now has a lot of features and works pretty much identical to Yarn so it isn't that much comparison going between both of those it is only personal preference and ease of use or performance issues.
Nodejs Default Package Manager
Fetches every package independently
Large support community
Easy for beginners and straight to the point
Alternative-Optimized Package Manager
Faster when it comes to fetching multiple packages
Caches All packages for quicker fetching
Has to install it separately by yourself
Say goodbye to “It works on my machine”
When it comes to package installation or updates Yarn is much faster compared to Npm since it uses a simultaneous package fetching and installation technique.