wclr / yalc

Work with yarn/npm packages locally like a boss.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to update yarn.lock on version bumps?

ivan-kleshnin opened this issue · comments

⚠️ It's probably a Yarn issue but I'd still like to share my use case as it's super trivial and replicable

yalc add updates yalc.lock but not yarn.lock (by design, I guess)
but yarn install does not pick consequent version changes either.

Note: I'm talking about Yarn 1.x.


  1. Imagine I added some local dependency from ptf-ui@0.4.3 with yalc add ptf-ui. The yalc.lock is properly created.

  2. Now I run yarn install and the following record appears in yarn.lock

"ptf-ui@file:.yalc/ptf-ui":
  version "0.0.43"
  1. Then I bump the dependency to ptf-ui@0.4.4 with another yalc add ptf-ui. The yalc.lock is properly updated.

  2. Now if I run yarn install it claims success Already up-to-date.

"ptf-ui@file:.yalc/ptf-ui":
  version "0.0.43" -- but in ".yalc/ptf-ui/package.json" the version is 0.0.44!

So now we have a mismatch error! Some tools which rely on node_modules will see a new version.
Other tools that rely on yarn.lock will see another version 😨

Which will lead to multiple subtle bugs, e.g. when deploying to Vercel it will skip yarn install step if nothing
was changed besides local dependencies. If I miss something obvious – please let me know.

commented

Well if you updated version of the package in .yalc/ptf-ui and yarn doesn't get it with yarn install, well this is how yarn works with local deps, may try some other yarn commands like upgrade (for the package) or something like that to make it grab this update.

Bingo yarn upgrade helped.

yarn upgrade <package_name>

I never used this command before, only yarn install. But for this case they work differently. Thank you ✋