yarn install in CI
yarn install installs from yarn.lock; in CI you want it to refuse lockfile changes.
Yarn Classic uses --frozen-lockfile; Yarn Berry (v2+) uses --immutable. Both fail the build if the lockfile would change.
Common flags
--immutable- Yarn 2+ reproducible install--frozen-lockfile- Yarn 1 equivalent--immutable-cache- also freeze the cache--inline-builds- show build script output
Example in CI
Reproducible install on Yarn Berry.
shell
yarn install --immutableIn CI
A lockfile-would-change failure means dependencies were edited without committing yarn.lock. Cache .yarn/cache for speed.
Key takeaways
- Yarn 2+:
--immutable; Yarn 1:--frozen-lockfile. - It fails if the lockfile would change.
- Cache
.yarn/cachebetween runs.