- upon release, yarn had many advantages compared to npm
- however, the rise of yarn pushed npm to make improvements and the competion has became increasingly tighten
- though, yarn is still (even after npm 6.0) somewhat faster
- the popularity gap is slowly closing but npm still is the most popular
- `sudo npm install -g yarn
curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
= update yarn
yarn init [-y]
yarn
oryarn install
= install all dependencies listed at 'package.json' and, if 'yarn.lock' exists and is enough to satisfy every dependency, the exact versions recorded in 'yarn.lock' are installed
yarn info package
= info about a package = now you can use yarn as package manager anywhere, just like npmyarn info package field
= select a specific field, e.g. description, versions, license
yarn list
= lists all dependencies for the current directoryyarn list --depth 0 --pattern "pattern"
yarn add [package]@[version]
= installyarn add [package] --dev|--peer|--optional
= different categories of dependencies
yarn global add package
= install globallyyarn outdated
= checks for outdated package dependenciesyarn upgrade [package]@[version]
= update dependencyyarn remove [package]
= remove dependency
yarn run scriptname
- yarn stores every package in a global cache in your user directory on the file system
yarn cache list
= view every cached packageyarn cache list --pattern "pattern"
- when you run either
yarn
oryarn add package
, Yarn will generate a yarn.lock - this file will ensure that they get precisely the same dependencies as you have, is equivalent to npm's 'package-lock.json' and 'pm-shrinkwrap.json'
- for development, a package can be linked into another project
- two steps:
yarn link
= in package you want to linkyarn link packagelinked
= link the linked package into current directory
yarn login
yarn publish
,yarn publish --new-version <version>
,yarn publish --access <public|restricted>
= publish current package- as of now, no command to unpublish