Getting Started with Yarn
Getting started with Yarn
Facebook has recently released a new JS package manager that sets out to fix / improve some of NPM’s weaknesses - Yarn.
If you have ever used NPM you may have experienced it’s weaknesses - slow, versioning issues around shrinkwrap, and semantik versioning that often updates packages without you meaning to - How many times did you get NPM errors and needed to rf -rf nodemodules && npm i ?!
Yarn is a new package manager that works with the existing NPM registry. It overcomes NPM’s non-determanistic dependency resolution by using lock files and an install algorithm that is deterministic and reliable. You can read more about it here.
To dive in you need to follow these simple steps (also possible in an existing npm based project):
npm i yarn -g
Yarn replaces the npm commands for installing and adding packages to your project:
- npm install –> yarn
- npm install –save [package-name] –> yarn add [package-name]
A yarn.lock file is created (similar to shrinkwrap) with the current versions and dependencies of each package.
Try removing the node_modules directory (rm -rf nodemodules) and running yarn - It’s blazing fast and reliable.
Let me know if it works for you!