Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I update/downgrade package version with yarn?

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

like image 510
Emre Avatar asked May 28 '20 07:05

Emre


People also ask

Does yarn upgrade update package json?

This is a command line utility program to upgrade all the packages in your package. json to the latest version (potentially upgrading packages across major versions).

Does yarn modify package json?

Running yarn upgrade without any modifiers does not update package. json . If we run yarn upgrade without any flags, it will install the latest version that matches the version pattern indicated by package. json .


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.
like image 162
hartshoj Avatar answered Oct 16 '22 16:10

hartshoj


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 
like image 27
Vimal Raj Avatar answered Oct 16 '22 17:10

Vimal Raj


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
like image 3
Emanuel Lindström Avatar answered Oct 16 '22 17:10

Emanuel Lindström