As far as I know, npm install -g yarn or sudo apt install yarn installs the legacy yarn version which is 1.22.x. If you want to migrate to yarn 4.x for a specific project, it is possible using yarn set version stable (or replace stable with the specific version to upgrade to). However, my use case required installing yarn 4.x globally as opposed to per project(which I know is discouraged in general) and I could not find any information on how to do that.
I managed to install yarn 4.x globally using Mise, a tool for configuring development environments.
mise use [email protected]mise use [email protected]After this, using yarn -v should show the correct version. Because I was using phpstorm, it only executes yarn from /bin/yarn, so I had to use a symlink to make it work.
which yarn)Stop installing yarn globally, use per-project yarn instead.
This allows migration per project.
Installing yarn by corepack enable is now the recommended way:
https://yarnpkg.com/migration/guide
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