How can I update global packages in Yarn?

Using yarn global add <package>@latest will upgrade a specific package if that is what you are trying to do.

Update

The recently added yarn global upgrade upgrades all packages. This did not exist at the time of the original answer.


TL;DR:

As webjay says, you simply:

yarn global upgrade

in yarn version 1.2.1 onwards.

For earlier versions:

(cd ~/.config/yarn/global && yarn upgrade)

Checking and repairing

Sadly, there is currently no yarn global check.

You can run yarn global add --force to reinstall all packages.

To check global packages, you can treat ~/.config/yarn/global/ like a local package, since:

  • ~/.config/yarn/global/package.json has dependencies for all global packages
  • ~/.config/yarn/global/node_modules contains all the global packages.

Check all global packages, and reinstall only if an error is found:

$ (cd ~/.config/yarn/global && yarn check || yarn install --force)