I tried some possible CLI commands but none seem to actually update the packages installed with yarn global add
.
yarn global upgrade
& yarn upgrade global
both don't work correctly. Is there a way of upgrading global packages?
In order to update your version of Yarn, you can run one of the following commands: npm install --global yarn - if you've installed Yarn via npm (recommended) curl --compressed -o- -L https://yarnpkg.com/install.sh | bash if you're on Unix. otherwise, check the docs of the installer you've used to install Yarn.
just run yarn upgrade-interactive --latest and select packages you want to update using space button and press the enter to update.
The global command makes executables available to use on your operating system. Note: Unlike the --global flag in npm, global is a command which must immediately follow yarn . Entering yarn add global package-name will add the packages named global and package-name locally instead of adding package-name globally.
As webjay says, you simply:
yarn global upgrade
in yarn
version 1.2.1 onwards.
For earlier versions:
(cd ~/.config/yarn/global && yarn upgrade)
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)
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.
There has been an issue created for this already at https://github.com/yarnpkg/yarn/issues/776
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With