Reputation:
I tried "npm update yarn -g" and "npm intall yarn -g", but the yarn verison is still 1.12.3.
I run the command in a empty folder, please see below. Thank you.
Microsoft Windows [Version 10.0.17134.320]
(c) 2018 Microsoft Corporation. All rights reserved.
D:\test>dir
Volume in drive D is D
Volume Serial Number is 18E2-7E00
Directory of D:\test
01/16/2019 10:38 PM <DIR> .
01/16/2019 10:38 PM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 467,370,369,024 bytes free
D:\test>npm update yarn -g
D:\test>yarn -v
1.12.3
D:\test>npm install yarn -g
C:\Users\myuser\AppData\Roaming\npm\yarn -> C:\Users\myuser\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js
C:\Users\myuser\AppData\Roaming\npm\yarnpkg -> C:\Users\myuser\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js
+ [email protected]
updated 1 package in 0.469s
D:\test>yarn -v
1.12.3
D:\test>npm -v
6.4.1
D:\test>
Upvotes: 30
Views: 41550
Reputation: 1
If you already have yarn in your machine, you just need to run
yarn set version stable
And yarn will upgrade to the latest stable version
Upvotes: 0
Reputation: 948
Firsly, you need to know the version you wanted, using npm view yarn versions
It'll show you list of yarn version like this.
[
'0.1.0', '0.1.1', '0.1.2', '0.1.3', '0.15.1',
'0.16.0', '0.16.1', '0.17.0', '0.17.2', '0.17.3',
'0.17.4', '0.17.5', '0.17.6', '0.17.7', '0.17.8',
'0.17.9', '0.17.10', '0.18.0', '0.18.1', '0.18.2',
'0.19.0', '0.19.1', '0.20.0', '0.20.3', '0.20.4',
'0.21.0', '0.21.1', '0.21.2', '0.21.3', '0.22.0',
'0.23.0', '0.23.1', '0.23.2', '0.23.3', '0.23.4',
'0.24.0', '0.24.1', '0.24.2', '0.24.3', '0.24.4',
'0.24.5', '0.24.6', '0.25.1', '0.25.2', '0.25.3',
'0.25.4', '0.26.0', '0.26.1', '0.27.0', '0.27.1',
'0.27.2', '0.27.3', '0.27.4', '0.27.5', '0.28.1',
'0.28.4', '1.0.0', '1.0.1', '1.0.2', '1.1.0',
'1.2.0', '1.2.1', '1.3.1', '1.3.2', '1.4.0',
'1.5.0', '1.5.1', '1.6.0', '1.7.0', '1.8.0',
'1.9.1', '1.9.2', '1.9.4', '1.10.0', '1.10.1',
'1.11.0', '1.11.1', '1.12.0', '1.12.1', '1.12.3',
'1.13.0', '1.14.0', '1.15.0', '1.15.1', '1.15.2',
'1.16.0', '1.17.0', '1.17.1', '1.17.2', '1.17.3',
'1.18.0', '1.19.0', '1.19.1', '1.19.2', '1.21.0',
'1.21.1', '1.22.0', '1.22.1', '1.22.4', '1.22.5',
'1.22.6', '1.22.7', '1.22.8', '1.22.9', '1.22.10',
'2.0.0-rc.24', '2.0.0-rc.27'
]
Then you can update with the following template.
npm install -g yarn@<version>
For example
npm install -g [email protected]
Upvotes: 1
Reputation: 361
To upgrade, download the latest installer at "https://yarnpkg.com/latest.msi"
But for some reason the download speed is slow.
Upvotes: 0
Reputation: 13719
Neither through the npm solution nor with yarn global
command I could get it properly updated. With the former it remained at the old version (as the question states) and the latter gave the warning:
Installing Yarn via Yarn will result in you having two separate versions of Yarn installed at the same time, which is not recommended.
And indeed, by doing where yarn
:
C:\Program Files (x86)\Yarn\bin\yarn
C:\Program Files (x86)\Yarn\bin\yarn.cmd
C:\Program Files (x86)\Yarn\bin\yarn.js
C:\Users\USER\AppData\Local\Yarn\bin\yarn
C:\Users\USER\AppData\Local\Yarn\bin\yarn.cmd
C:\Users\USER\AppData\Roaming\npm\yarn
C:\Users\USER\AppData\Roaming\npm\yarn.cmd
Previously it was only installed in Program Files and after yarn global add yarn
the new version went to AppData, but according to yarn -v
the one being used was still the old one.
Therefore, using windows "Add or remove programs", I removed yarn manually which made the old version (on Program Files) to be removed leaving just the AppData one (latest version at this time: 1.22.4).
As the warning also recommended:
To update Yarn please follow https://yarnpkg.com/en/docs/install
As the people developing yarn suggest, I suppose things are less likely to go wrong using the installer.
Upvotes: 2
Reputation: 1353
There is a known bug on npm update yarn -g
here is the related GitHub issue so you should use this instead:
npm install -g yarn
Alternatively, you can install brew
first than update trough brew
like this:
brew upgrade yarn
If you're using Windows you can find a brew
alternative, such as choco
, and update with like this:
choco upgrade yarn
Upvotes: 41
Reputation: 12766
The question shows that yarn has been upgraded with npm install yarn -g
to 1.13.0 but the yarn command is still showing an older version
D:\test>yarn -v
1.12.3
The most likely problem is because the executed yarn version is as expected, C:\Users\myuser\AppData\Roaming\npm\yarn
. Check which version of yarn you are invoking with
D:\test>where yarn
@Whatatimetobealive's answer is the best option to upgrade yarn. If for some reason you cannot use choco
, brew
, npm
or your package manager to install yarn, you can try using yarn
itself.
$ yarn global add yarn
Unfortunately we cannot use yarn to update itself until the yarn self-update
command is fixed.
Upvotes: 6