DEV Community

Darragh O'Riordan
Darragh O'Riordan

Posted on • Originally published at darraghoriordan.com on

6 1

How to also update the package.json version when using yarn update

If you run yarn update on a package, yarn will update the package and your yarn.lock file. This is totally fine.

As long as you check in your lock file, your developers and team will all have the correct versions of libraries when they run yarn install.

However it will not update the package.json with the new semver for the package.

I kind of found this annoying. If only for aesthetic reasons I wanted to quickly see which minimum versions of packages I was using in my package.json.

To have yarn also update the package.json semver there are a couple of options. Essentially you need to add —latest

Using —latest

If you have pass yarn the --latest flag it will update the package.json.

NOTE: this will not respect semver and will update to the latest version. Whatever that might be.

yarn upgrade @graphql-codegen/cli --latest
Enter fullscreen mode Exit fullscreen mode

Using interactive upgrade —latest

If you use the interactive upgrade it will also upgrade the package.json for you

yarn upgrade-interactive --latest
Enter fullscreen mode Exit fullscreen mode

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (1)

Collapse
 
arpitprod profile image
arpitprod

yarn upgrade-interactive --latest

This command is not updating all packages.

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay