问题
How should yarn
be upgraded to the latest version?
回答1:
For macOS users, if you installed yarn
via brew
, you can upgrade it using the below command:
brew upgrade yarn
回答2:
npm install --global yarn
npm upgrade --global yarn
This should work. Try and let me know if its not working.
回答3:
On Linux, just run below command at terminal:
$ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
After do this, close the current terminal and open it again. And then, run below command to check yarn current version:
$ yarn --version
回答4:
Not remembering how i've installed yarn the command that worked for me was:
yarn policies set-version
This command updates the current yarn version to the latest stable.
From the documentation:
Note that this command also is the preferred way to upgrade Yarn - it will work no matter how you originally installed it, which might sometimes prove difficult to figure out otherwise.
Reference
回答5:
For Windows users
I usually upgrade Yarn with Chocolatery
choco upgrade yarn
回答6:
npm install -g yarn
- solved the issue when nothing happened running npm update --global yarn
.
Alternative method to update yarn: curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
.
Mac users with homebrew can run brew upgrade yarn
.
More details here and here.
回答7:
I had an outdated symlink that was preventing me from accessing the proper bin. I had also recently gone through a node upgrade which means a lot of my newer bins were available in a different folder with what i think was a lower priority
Here is what worked for me:
yarn -v
> 1.15.2
which yarn
> /Users/lfender/.yarn/bin/yarn
rm -rf /Users/lfender/.yarn/bin/yarn
npm uninstall --global yarn; npm install --global yarn
> + yarn@1.16.0
> added 1 package in 0.179s
which yarn
> /Users/lfender/.nvm/versions/node/v12.2.0/bin/yarn
yarn -v
> 1.16.0
If you are not using NVM, the location of your bin installs are likely to be unique to your system
From there, I've switched to doing yarn policies set-version
as outlined here https://stackoverflow.com/a/55278430/1426788 to define my yarn version at the repo level
回答8:
- Add Yarn Package Directory:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- Install Yarn:
sudo apt-get update && sudo apt-get install yarn
Please note that the last command will upgrade yarn to latest version if package already installed.
For more info you can check the docs: yarn installation
回答9:
I updated yarn on my Ubuntu by running the following command from my terminal
curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
source:https://yarnpkg.com/lang/en/docs/cli/self-update
回答10:
yarn policies set-version
will download the latest stable release
Referenced yarn docs https://yarnpkg.com/lang/en/docs/cli/policies/#toc-policies-set-version
回答11:
Since you already have yarn installed and only want to upgrade/update. you can simply use
yarn self-update
Find ref here https://yarnpkg.com/en/docs/cli/self-update
来源:https://stackoverflow.com/questions/49689174/how-to-upgrade-yarn-version-using-terminal