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
updatesyalc.lock
but notyarn.lock
(by design, I guess)
butyarn install
does not pick consequent version changes either.
Note: I'm talking about Yarn 1.x.
-
Imagine I added some local dependency from
ptf-ui@0.4.3
withyalc add ptf-ui
. Theyalc.lock
is properly created. -
Now I run
yarn install
and the following record appears inyarn.lock
"ptf-ui@file:.yalc/ptf-ui":
version "0.0.43"
-
Then I bump the dependency to
ptf-ui@0.4.4
with anotheryalc add ptf-ui
. Theyalc.lock
is properly updated. -
Now if I run
yarn install
it claimssuccess 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.
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 ✋