Interactive Package Updates With Yarn

Last Updated: February 4, 2020.

Quick questions:

Have you ever needed to update an installed npm package to its latest release?

How have you gone about it in the past?

If you make use of yarn as the primary tool for managing dependencies, using the interactive yarn upgrade command may be a much nicer path to take.

Yarn Logo

Updating Project Dependencies

To interactively update a local project’s dependencies, running the following command in the desired project’s directory:

yarn upgrade-interactive

Upon running the above command, an interactive shell environment would be presented where you can toggle which of the project’s dependencies you wish to upgrade.

The interactive environment which you would see should be something akin to this:

yarn upgrade-interactive environment

Side Note: Be sure to take note of the color legend provided which provides hints following semver.

Updating Global Packages

While the aforementioned command is specific to updating a particular project’s packages, interactive updates can also be done for global packages – again, if you are using yarn as your global package manager.

Running …

yarn global upgrade-interactive

… will bring up a similar interactive shell as the above where you can selectively update global packages.

yarn global upgrade-interactive environment

Using NPM?

The NPM CLI doesn’t have a native tool to do this as at the time of publishing this note, but you can check out npm-check