Node.js – How to update “yarn” to the latest version, 1.13.0

node.jsnpmyarnpkg

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
+ yarn@1.13.0
updated 1 package in 0.469s

D:\test>yarn -v
1.12.3

D:\test>npm -v
6.4.1

D:\test>

Best Answer

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