About NPM and Yarn
NPM and Yarn are package managers that help to manage a project’s dependencies.
NPM
- It is a package manager for the JavaScript programming language.
- It is the default package manager for the JavaScript runtime environment Node.js
Yarn
- It was developed by Facebook
- It is open-source
The intention behind developing yarn(at that time) was to fix performance and security concerns with npm.
Installation
- npm: npm is installed with Node automatically.
yarn: To install yarn npm have to be installed.
npm install yarn --global
The lock file
- NPM generates a ‘package-lock.json’ file.
- Yarn generates a ‘yarn.lock’ file.
Installing global dependencies
npm: To install a global package, the command template for npm is:
npm install -g package_name@version_number
yarn: To install a global package, the command template for yarn is:
yarn global add package_name@version_number
Pros and cons
Npm
- Come with node
- big community
Yarn
- fast
- offline mode
- yarn why (to track dependences)
Sources link
https://www.geeksforgeeks.org/difference-between-npm-and-yarn/