Install dependencies:
yarn
yarn install # or this
yarn install --frozen-lockfile # for CIAdd a dependency:
yarn add <package name>
yarn add <package name> --dev # for a dev dependency
yarn global add <package name> # for a global installUpgrade a dependency:
yarn upgrade <package name>
yarn upgrade-interactive # interactive way of upgradingRemove a dependency:
yarn remove <package name>Note: No need to specify a flag, e.g. --dev.
Run a user-defined script:
yarn dev # for a `dev` entry in `scripts` in `package.json`
yarn run dev # or thisNote: To pass arguments just add them like so: yarn dev --foo --bar
Run locally installed CLIs:
yarn speed-test # for running `speed-test` if specified in `package.json`Generate a yarn.lock file from a package-lock.json:
yarn importNote: Delete the package-lock.json file if you intend to use Yarn (v1), and use the yarn.lock file instead.
Generate a list of licenses from your dependencies:
yarn licenses generate-disclaimerCheck if installed packages are currently outdated:
yarn outdatedEnforce usage of a specific version of Yarn:
yarn policies set-version <version>Note: This will generate a .yarnrc file, and download a Yarn executable to .yarn/releases/. These should be committed to source control.
Enable PnP (i.e. Plug’n’Play):
rm -rf node_modules
yarn --pnpNote: This will remove the node_modules folder (unnecessary), create a yarn.lock (if not already present), add installConfig.pnp: true to package.json, and generate a .pnp.js file and a .pnp/ folder. You should commit the .pnp/ folder to source control, and ignore the .pnp.js file.