Yarn is a new package manager that we built to be consistent and reliable. When installing hundreds or even thousands of third-party packages from the internet you want to be sure that you’re executing the same code across every system.
Why Yarn?
Yarn provides a rich set of command-line commands to help you with various aspects of your Yarn package, including installation, administration, publishing, etc.
In most cases yarn commands are the same as npm, but there are some exceptions:
npm install
is now justyarn
npm install fabric --save
isyarn add fabric
npm uninstall taco --save
isyarn remove taco
npm install taco --save-dev
isyarn add taco --dev
npm update --save
isyarn upgrade
npm install taco --global
isyarn global add taco
npm run debug
is eitheryarn run debug
or justyarn debug
yarn why taco
— Identify why ‘taco’ package is installed, detailing which other packages depend upon it
View more on command changes.
Advantage
- From the get-go, the Yarn lockfile guarantees that repeatedly running yarn on the same repository results in the same packages.
- Second, Yarn attempts to have good performance, with a cold cache, but especially with a warm cache.
- Finally, Yarn makes security a core value. NO
npm cache clean && rm -rf node_modules
anymore.