DEV Community

loading...

Discussion on: Updating Dependencies While Keeping package.json and yarn.lock in Sync

Collapse
talha131 profile image
Talha Mansoor

yarn upgrade-interactive --latest would update all the packages. But if you only want to update a single package, for example react, you can do yarn upgrade react@^. This command will update both yarn.lock and package.json files.

Collapse
thawkin3 profile image
Tyler Hawkins Author

That's mostly correct. yarn upgrade-interactive --latest gives you the option to upgrade all the packages, since you can choose which ones to upgrade interactively. The benefit here is if you're upgrading many packages and don't want to type out each one. For example, I recently had to update about 30 packages. I definitely don't want to have to type out each package name with a command like yarn upgrade react@^ package-2@^ package-3@^ ....

Collapse
talha131 profile image
Talha Mansoor

I see your point. In one my projects, the build started to fail after I upgraded all the packages at the same time. After a lot of head scratching, I upgrade the packages one by one. This fixed the build issue.

I am not sure what the reason was. But since then, I have become weary of upgrade all commands.

Thread Thread
thawkin3 profile image
Tyler Hawkins Author

For sure, I probably wouldn't just upgrade all the packages at once. That's why I like to use the interactive command, upgrade the patch and minor updates together, make sure the tests pass, and then handle the major upgrades one by one since those have the breaking changes that could go wrong.