Jakub notes • engineering

Yarn 1 (Classic)

Enforcing Yarn’s version

A different version of Yarn within a team might sometimes cause issues. Setting the version in enginesinside package.json would technically solve the issue but yarn policies set-version adds exact Yarn release into repository so it doesn't require to upgrade global Yarn.

yarn policies set-version latest

It will add config file .yarnrc and yarn binary used for the project.

yarn-path ".yarn/releases/yarn-1.22.10.js"

yarn-pathwas introduced in Yarn 1.0, so the project should have at least "yarn": "^1.0.0" and yarn-path in.yarnrc makes sure it'll use proper version.

{
  "engines": {
    "yarn": "^1.0.0"
  }
}

--frozen-lockfile

Usually used in CI. Don’t generate a yarn.lock lockfile and fail if an update is needed. That could be caused e. g. when dependency version is updated manually in package.json.

yarn install --frozen-lockfile

Deprecated

Workspaces experimental options

workspaces and nohoist is no more experimental since Yarn 1.0 and are on by default. Options can still be used to turn off the functionality but it is stable enough so no need for that.

workspaces-experimental true
workspaces-nohoist-experimental true

User options

.yarnrc should not contain lastUpdateCheck, email, username. Those are user specific values. https://github.com/yarnpkg/yarn/issues/4134#issuecomment-627655554 lastUpdateCheck is stored in global ~/.yarnrc.