How to Upgrade a Yarn Package to the latest version

We all have been there at one point, trying to upgrade a yarn package but don't know-how. I'm writing this article because I found myself in that position, and would be using this as a reference in the near future.

Let's get started

Let's use upgrading "@pointblankdev/dynamite" in a project as an example

Which version

Check the current version installed

We can see that the package here is 1.0.1

yarn why @pointblankdev/dynamite
Screenshot 2021-07-25 at 6.36.00 AM.png

Lets Upgrade the Package

To upgrade the package, we just do yarn upgrade "@pointblankdev/dynamite" --latest, if we upgrade without the --latest flag, the current version specified in the package.json will be used(the outdated version)

Screenshot 2021-07-25 at 6.52.48 AM.png

Both package.json and yarn.lock


Running yarn why @pointblankdev/dynamite and yarn list --pattern @pointblankdev/dynamite will show the version of the package

You can also use yarn upgrade [package ][package@version] to upgrade a specified version