Notes

Yarn 2.0

Edit on GitHub

Node

Why Yarn?

  • it’s not the speed anymore, it’s the change in approaches to dependency management. i like Yarn’s approach and explanation better
  • Plug’n’Play is cool. Instead of installing a bajillion files, you can have just one file called .pnp.cjs instead of a whole folder called node_modules in EVERY project. (React Native isn’t yet supported though).
  • See all available commands with yarn help
1npm i -g yarn

Set version to Yarn 2.0 (aka berry) inside your project

1yarn set version berry

Set global config

1yarn config set init-license 'CC-BY-SA-4.0' -g
2yarn config set init-version '0.0.1' -g
 1# Accessing the list of commands
 2yarn help
 3
 4# Starting a new project
 5yarn init
 6
 7# Installing all the dependencies
 8yarn
 9yarn install
10
11# Adding a dependency
12yarn add [package]
13yarn add [package]@[version]
14yarn add [package]@[tag]
15
16# Adding a dependency to different categories of dependencies
17yarn add [package] --dev  # dev dependencies
18yarn add [package] --peer # peer dependencies
19
20# Upgrading a dependency
21yarn up [package]
22yarn up [package]@[version]
23yarn up [package]@[tag]
24
25# Removing a dependency
26yarn remove [package]
27
28# Upgrading Yarn itself
29yarn set version latest
30yarn set version from sources