244

How can I uninstall yarn? I've used it for a react-native project and now whenever I move the code out of index.ios.js or index.android.js it throws an error so I'd like to just use npm but whenever I initialize a react-native project it defaults to yarn. I tried npm uninstall yarn but that didn't work. Thanks.

Shaun Roselt
  • 1,650
  • 5
  • 18
  • 44
maxwellgover
  • 6,661
  • 9
  • 37
  • 63
  • 10
    Do you have it installed globally? `npm uninstall -g yarn`. Maybe it would be better to fix the problems you encounter moving code, though… – Ry- Feb 20 '17 at 01:12
  • 2
    That didn't work. Still using Yarn. – maxwellgover Feb 20 '17 at 01:18
  • You might have to delete the associated files. Like the yarn lock file etc.. – inoabrian Feb 20 '17 at 20:07
  • 2
    You have to uninstall this with program which you've used when installed it. npm list -g --depth=0 shows your global npm packages. In my situation I have installed yarn with brew on MacOS, so ```brew uninstall yarn``` worked perfect for me – Kirill Husiatyn Jun 27 '17 at 08:29
  • npm uninstall -g yarn worked for me – Learner Mar 18 '20 at 06:12

30 Answers30

424

Depends on how you installed it:

brew: brew uninstall yarn

tarball: rm -rf "$HOME/.yarn"

npm: npm uninstall -g yarn

ubuntu: sudo apt-get remove yarn && sudo apt-get purge yarn

centos: yum remove yarn

windows: choco uninstall yarn (or go to control panel > add/remove programs and uninstall it from there)

Redoman
  • 3,059
  • 3
  • 34
  • 62
sospedra
  • 14,238
  • 3
  • 21
  • 32
  • 84
    `npm uninstall -g yarn` doesn't work. It simply reports `up to date in 0.067s` and does nothing. – Vince Jan 21 '19 at 10:56
  • I've tried all of these that apply (unbuntu), but I get `$ eslint bash: /home/.../.yarn/bin/eslint: No such file or directory` – Max Waterman Jan 31 '19 at 10:06
  • 1
    To answer my own question - use `hash -r` to clear bash's hash and avoid restarting your shell. – Max Waterman Jan 31 '19 at 10:19
  • what is this ? "windows" "npm".... the npm is already in windows! probably you meant choco? you messing OS with other packages... a mess... – serge Jan 31 '19 at 18:01
  • 1
    @Vince Maybe you are on Windows? If so, see the answers of Alireza Fattahi and Raja Rahul on how to overcome the problem you mentioned. – user1460043 Feb 22 '19 at 15:02
  • 2
    I am on windows. I tried the advice here and tried finding where on windows my yarn was installed. So, I ran the command "which yarn" (I have cygwin installed) -- I found that yarn was installed in the "Program Files (x86)" directory -- so I knew that it was a standalone installation and was not part of choco or npm, etc. So, I uninstalled it from the OS installed software list. – anjanb Jun 23 '20 at 06:38
  • @anjanb no need for cygwin/which, nowadays windows has "where". – Redoman Mar 19 '21 at 00:54
  • 2
    **windows:** Control Panel -> Programs And Features -> Yarn -> Uninstall – flm Feb 02 '22 at 16:43
  • on Mac, I run sudo npm uninstall -g yarn – zdravko zdravkin Jul 09 '22 at 05:55
193

Try this, it works well on macOS:

$ brew uninstall --force yarn
$ npm uninstall -g yarn
$ yarn -v

v0.24.5 (or your current version)

$ which yarn

/usr/local/bin/yarn

$ rm -rf /usr/local/bin/yarn
$ rm -rf /usr/local/bin/yarnpkg
$ which yarn

yarn not found

$ brew install yarn 
$ brew link yarn
$ yarn -v

v1.17.3 (latest version)

Or you could install it as recommended on the website (https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable) through npm using:

$ npm install --global yarn
iji
  • 392
  • 1
  • 2
  • 13
Jan Jarčík
  • 2,681
  • 2
  • 18
  • 21
54

Didn't see the answer that worked for me, so here it is: On my OSX system I found yarn at ~/.yarn/bin/yarn. rm -rf ~/.yarn took care of it.

elthrasher
  • 1,132
  • 9
  • 6
33

on windows: Go to "Add or remove programs" in control panel (or open the start menu and search for "remove program")

https://github.com/yarnpkg/yarn/issues/3331

Alireza Fattahi
  • 42,517
  • 14
  • 123
  • 173
29

If you are using corepack and previously ran the command corepack enable, then you can uninstall yarn via the following command:

corepack disable yarn
Bruno
  • 6,211
  • 16
  • 69
  • 104
  • I also installed Yarn through corepack. I tried this , its not working. corepack is the recommended way they put on there website to install "Yarn" now. But there is no command for Uninstalling Yarn on there website. if you know of another way to uninstall "Yarn", for people that originally installed it through corepack. Please let me know. – Calculate Nov 16 '22 at 02:26
  • Update, the command you put worked. I just had to enter the command inside the "Run as Administrator" mode in the "Command Prompt", since this was how i originally installed it. Thankyou, – Calculate Nov 16 '22 at 05:17
16

If you installed with brew, try brew uninstall yarn at terminal prompt. Also remember to remove yarn path info in your .bash_profile.

Christian Giupponi
  • 7,408
  • 11
  • 68
  • 113
10

I'm using macOS. I had a few versions of yarn installed with Homebrew, which I uninstalled with brew uninstall --force yarn. I then installed the latest version 1.7.0 of Yarn using Homebrew brew install yarn

But still when I ran which yarn, it returned /Users/Me/.yarn/bin/yarn, and yarn --version returned 0.24.6. There was no mention of Yarn in ~/.bash_profile, but my ~/.bashrc file contained the line export PATH="$HOME/.yarn/bin:$PATH" indicating that I must have previously installed Yarn globally, but I only wanted to use the latest version that I just installed with Homebrew.

So I uninstalled Yarn globally by running npm uninstall -g yarn; rm -rf ~/.yarn, then editing the file ~/.bashrc by changing the line to export PATH="/usr/local/bin/yarn:$PATH" and running source ~/.bashrc to update the PATH in the terminal session. Then when I ran which yarn it returned /usr/local/bin/yarn, and when I ran yarn --version it returned 1.7.0

Luke Schoen
  • 4,129
  • 2
  • 27
  • 25
9

In case you installed yarn globally like this

$ sudo npm install -g yarn

Just run this in terminal

$ sudo npm uninstall -g yarn

Tested now on my local machine running Ubuntu. Works perfect!

8

I tried the Homebrew and tarball points from the post by sospedra. It wasn't enough.

I found yarn installed in: ~/.config/yarn/global/node_modules/yarn

I ran yarn global remove yarn. Restarted terminal and it was gone.

Originally, what brought me here was yarn reverting to an older version, but I didn't know why, and attempts to uninstall or upgrade failed.

When I would checkout an older branch of a certain project the version of yarn being used would change from 1.9.4 to 0.19.1.

Even after taking steps to remove yarn, it remained, and at 0.19.1.

mbd
  • 81
  • 1
  • 4
6

What I've done on my side:

Went to the /usr/local/lib/node_modules, and deleted the yarn folder inside it.

Edmundo Santos
  • 8,006
  • 3
  • 28
  • 38
6

I couldn't uninstall yarn on windows and I tried every single answer here, but every time I ran yarn -v, the command worked. But then I realized that there is another thing that can affect this.

If you on windows (not sure if this also happens in mac) and using nvm, one problem that can happen is that you have installed nvm without uninstalling npm, and the working yarn command is from your old yarn version from the old npm.

So what you need to do is follow this step from the nvm docs

You should also delete the existing npm install location (e.g. "C:\Users<user>\AppData\Roaming\npm"), so that the nvm install location will be correctly used instead. Backup the global npmrc config (e.g. C:\Users&lt;user>\AppData\Roaming\npm\etc\npmrc), if you have some important settings there, or copy the settings to the user config C:\Users&lt;user>.npmrc.

And to confirm that you problem is with the old npm, you will probably see the yarn.cmd file inside the C:\Users\<user>\AppData\Roaming\npm folder.

Vencovsky
  • 28,550
  • 17
  • 109
  • 176
5

npm uninstall yarn removes the yarn packages that are installed via npm but what yarn does underneath the hood is, it installs a software named yarn in your PC. If you have installed in Windows, Go to add or remove programs and then search for yarn and uninstall it then you are good to go.

Raja Rahul
  • 71
  • 1
  • 3
4

For Windows User:

Just use the installer file(i.e yarn-1.22.4.msi in my case) to uninstall yarn.

Once you open the installer you will get three options, i.e to install, repair and uninstall yarn from your machine. Select uninstall and it will remove all the yarn files from your pc.

3

On my Mac neither of these regular methods to uninstall Yarn worked:

brew: brew uninstall yarn

npm: npm uninstall -g yarn

Instead I removed it manually by typing rm -rf ~/.yarn (thanks user elthrasher) and deleting the two symbol links yarn and yarnpkg from usr/local/bin. Afterwards brew install yarn gave me the latest version of Yarn.


Background: The fact that I had a very outdated version of Yarn installed gave me utterly incomprehensible errors while trying to install additional modules to a project set up with Vue CLI Service and Vue UI, which apparently uses Yarn 'under the hood'. I generally use NPM so it took me a while to figure out the cause for my trouble. Naturally googling error messages produced by such module incompatibilities presented no clues. With Yarn updated everything works just perfectly now.

Oliver Schafeld
  • 17,358
  • 2
  • 15
  • 13
3

For windows user:

npm uninstall -g yarn

For Mac user:

$ npm uninstall -g yarn

It will completely be remove yarn for your system.

Luis Paulo Pinto
  • 5,578
  • 4
  • 21
  • 35
Asim Khan
  • 309
  • 3
  • 2
3

If on your system, Yarn is provided from Node.js, through corepack, then, you can choose which version of Yarn you want to use, with the following:

corepack prepare yarn@x.y.z --activate

–as per https://nodejs.org/api/corepack.html#upgrading-the-global-versions

Aekzo
  • 31
  • 2
2

In the case of windows, after executing npm uninstall -g yarn, still if yarn did not uninstalled, then go to "C:\Users\username\AppData\Local" and remove the yarn folder.

Close the cmd and reopen the cmd and execute yarn . it will give you message 'yarn' is not recognized as an internal or external command, operable program or batch file.

Skatox
  • 4,237
  • 12
  • 42
  • 47
anil
  • 653
  • 1
  • 5
  • 14
2

If you are still getting errors after deleting ~/.yarn about files not being found, don't forget to delete the yarn rc file:

rm ~/.yarnrc.yml 
robrecord
  • 504
  • 5
  • 15
1

This is how to uninstall yarn completely for Mac Users

sudo npm uninstall -g yarn
Dennis
  • 99
  • 4
1

I found the other answers a bit inadequate since I wanted to "completely" remove yarn from my Mac (M1). I found this worked:

  1. First remove it how you installed it i.e. same as this.
  2. Remove the cache. For example on my Mac I ran:
rm -rf ~/Library/Caches/Yarn
  1. Remove the global node_modules cache of Yarn:
rm -rf ~/.config/yarn

yarn cache clean did not help get rid of the above which tool significant space.

  1. Remove any other Yarn-related config files:
rm -rf ~/.yarn
rm ~/.yarnrc
Saifur Rahman Mohsin
  • 929
  • 1
  • 11
  • 37
1

As of 2023: If you used Corepack to active Yarn, you can run the following

corepack disable
yarn -v

Then, remove any temp folders and files. This works if you didn't originally install Yarn using npm install --force -g yarn. Corepack doesn't let you have multiple instances of Yarn if you activated Yarn using Corepack. Hence, why some might use --force.

Corepack docs on Yarn. Yarn docs on Yarn2.x (not classic version 1.x)

1

Yarn v3^ doesn't install via npm.

It installs via corepack. See installation instructions.

If your install process looked like:

corepack enable
corepack prepare yarn@stable --activate

And, if you're on Ubuntu (or perhaps similar, I only tested on Ubuntu), then your uninstall process will look like:

yarn --version

Returns:

3.50

You're on yarn v3! Find out where it's installed.

which yarn

Returns

/home/caleb/.nvm/versions/node/v16.13.2/bin/yarn

Delete from nvm

rm -rf ~/.nvm/versions/node/v16.13.2/bin/yarn
rm -rf ~/.nvm/versions/node/v16.13.2/bin/yarnpkg

Doing yarn now will resolve to /usr/local/bin/yarn so you need to delete that as well.

yarn --version
which yarn

returns:

bash: /home/caleb/.nvm/versions/node/v16.13.2/bin/yarn: No such file or directory
/usr/local/bin/yarn

So remove that as well. You might need sudo. Especially when using sudo, you should not blindly copy/paste commands you find on the internet, so type out the below manually.

sudo rm -rf /usr/local/bin/yarn

Now yarn should be uninstalled.

yarn --version

Returns:

Command 'yarn' not found, but can be installed with:
sudo apt install cmdtest
Caleb Jay
  • 2,159
  • 3
  • 32
  • 66
0

Try "npm uninstall -g yarnpkg"(global) or "npm uninstall yarnpkg"(local) if you installed it with npm.
That's what worked for me.
If that still doesn't work and you installed it with npm,
do "npm list -g" to check if you installed it globally or "npm list" if you installed it locally.
Hope that helps anyone having this problem. :D

EDIT: Found something if you installed yarn with .msi executable you have to install it the normal windows way.

  • This does nothing (just like `npm uninstall -g yarn`). I did install yarn globally, but `npm list -g` doesn't show anything containing the string `yarn`. – Vince Jan 21 '19 at 11:11
  • This worked for me where `npm uninstall -g yarn` did not – Amicable Dec 05 '19 at 11:57
0

I had to manually remove(delete) the Yarn folder from drive and then run npm uninstall -g yarn again to reinstall it. It worked for me.

Mahipal
  • 344
  • 2
  • 13
0

remove yarn

# macOS & brew
$ brew uninstall yarn

remove npm package

# yarn global remove
$ sudo yarn global remove @tarojs/cli


# yarn global add 
$ sudo yarn global add @tarojs/cli

refs:

https://classic.yarnpkg.com/en/docs/cli/global/

https://classic.yarnpkg.com/en/docs/cli/remove/

desertnaut
  • 57,590
  • 26
  • 140
  • 166
xgqfrms
  • 10,077
  • 1
  • 69
  • 68
0

For Windows:

I need to do these steps to completely remove the yarn from the system.

  1. Go to add or remove programs and then search for yarn and uninstall it(if you installed it with the .msi)
  2. npm uninstall -g yarn (if you installed with npm)
  3. Remove any existing yarn folders from your Program Files (x86) (Program Files (x86)\Yarn).
  4. Also need to delete your Appdata\local\yarn folder ( type %LOCALAPPDATA% in the run dialog box (win+R), it opens a local folder and there you'll find the yarn folder to delete)
  5. Finally,check your user directory and remove all .yarn folder, .yarn.lock file, .yarnrc etc ( from C:\Users\<user>\)
anju
  • 589
  • 12
  • 25
0

It really works when I'm still getting errors after deleting ~/.yarn

rm ~/.yarnrc.yml

We must delete .yarnrc.yml or .yarnrc file

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129
2cutecats
  • 1
  • 1
0

I had an error with re-linking and bin logs:

error Could not write file "/yarn-error.log": "EROFS: read-only file system, open '/yarn-error.log'" error An unexpected error occurred: "EROFS: read-only file system, mkdir '/node_modules'". info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

To solve this I did this:

cd /tmp
mkdir yarntest
cd yarntest
yarn add react || fail_with_log
Asplund
  • 2,254
  • 1
  • 8
  • 19
-2

ng set --global packageManager=npm OR ng set --global packageManager=yarn

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
-2

Just copy this command and your problem will be fixed.

npm uninstall yarn

Skatox
  • 4,237
  • 12
  • 42
  • 47