How can I update/downgrade package version with yarn?

Viewed 47959

I have a package and I want to downgrade the version use. How can I do this with yarn "dependencies"?

3 Answers
Yarn version Command Example
1 yarn upgrade package@version yarn upgrade luxon@^3.0.1
2, 3 yarn up package@version yarn up luxon@^3.0.1
  • Use yarn -v to check your Yarn version.
  • Though the command is upgrade, it can be used for downgrading too.

This is the official documentation https://classic.yarnpkg.com/en/docs/cli/upgrade There is no keyword for downgrading to a specific version.you have to use the upgrade keyword for both

yarn upgrade package@version

For example

yarn upgrade @types/express-session@^1.15.16 

You can upgrade/downgrade a package interactively like so:

yarn upgrade my_package@^

This will produce an interactive list of available versions for the package for you to choose from. Like so:

Couldn't find any versions for "my_package" that matches "^"
? Please choose a version of "my_package" from this list: (Use arrow keys)
❯ 0.10.1
  0.10.0
  0.9.3
  0.9.2
  0.9.1
  0.9.0
  0.8.2
  0.8.0
Related