npm (Node Package Manager):- npm is a command line client and a database made up of public and premium packages known as the the npm registry. Users can access the registry via the client and browse the many packages available through the npm website. npm and its registry are managed by npm, Inc.
npm install command installs dependencies from the package.json file
npm install <package> command, it also automatically saves references to the packages in the package.json file.
Yarn:- Yarn was developed by Facebook in attempt to resolve some of npm’s shortcomings. Yarn as a new installer that relies upon the same npm structure. The registry itself hasn’t changed, but the installation method is different. Since Yarn gives you access to the same packages as npm, moving from npm to Yarn doesn’t require you to make any changes to your workflow.
yarn, installs dependencies listed in the yarn.lock file.
yarn add <package> command lets you add dependencies
Try out Yarn on an existing npm project, just run: