How to uninstall YARN on Windows, MacOS and Linux

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
5 min

banner

# Table of Contents

  1. How to uninstall YARN on Windows, MacOS and Linux
  2. Uninstalling YARN on Windows
  3. Uninstall YARN on macOS
  4. Uninstalling YARN on Linux
  5. Uninstalling yarn with Corepack
  6. Uninstall yarn from a project

# How to uninstall YARN on Windows, MacOS and Linux

If you've installed yarn using npm, you can uninstall it by running the npm uninstall -g yarn command in your terminal.

shell
npm uninstall -g yarn

If you get a permissions error on macOS or Linux, try to rerun the command prefixed with sudo.

shell
sudo npm uninstall -g yarn

If you get a permissions error on Windows, open CMD (Command Prompt) as an administrator and rerun the command.

To open CMD as an administrator:

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

  1. Rerun the command.
cmd
npm uninstall -g yarn

You can check if yarn has been uninstalled by issuing the yarn --version command.

shell
yarn --version

If that doesn't work, follow the operating system-specific instructions on how to uninstall yarn.

# Uninstalling YARN on Windows

If you installed yarn on Windows using Chocolatey, to uninstall the package:

  1. Open PowerShell as an administrator.

Click on the Search bar and type "PowerShell".

Right-click on the "PowerShell" application and click "Run as administrator".

run powershell as administrator

  1. Run the following command to uninstall yarn.
PowerShell
choco uninstall yarn -y

uninstall yarn on windows using chocolatey

Otherwise, to uninstall yarn on Windows:

  1. Click on the search field and type add remove program.

windows search add remove program

  1. Select Add or remove programs from the list of options.

  2. Either search for yarn or scroll down until you find the yarn program.

uninstall yarn from add or remove programs menu

  1. Click on it and select Uninstall.

After you uninstall yarn issue the yarn --version command to verify.

shell
yarn --version

You might also have to run the npm uninstall -g yarn command.

shell
npm uninstall -g yarn

# Uninstall YARN on macOS

To uninstall yarn on macOS, run the following command from your terminal.

shell
brew uninstall --force yarn

You might also have to run the following command.

shell
npm uninstall -g yarn

Check if yarn is installed by issuing the yarn --version command.

If you still get output from the command, run the which yarn command.

shell
which yarn

You might also have to delete the yarn directory manually from your terminal.

shell
rm -rf /usr/local/bin/yarn rm -rf /usr/local/bin/yarnpkg rm -rf ~/.yarn

Make sure to replace the path with the output you got from the which yarn command.

Try to rerun the which yarn command.

shell
which yarn

If you still get output, delete the yarn directory using the rm -rf command.

You can also check if yarn is installed by running the yarn --version command.

shell
yarn --version

If you need to reinstall yarn, run the following commands.

shell
brew install yarn brew link yarn

Verify that yarn is installed.

shell
yarn --version

You can also install yarn using npm.

shell
npm install -g yarn

Make sure that the path to YARN has not been added to your ~/.bashrc, ~/.bash_profile or ~/.zshrc file.

For example, you might have the following line in your profile file.

~/.bashrc
export PATH="$HOME/.yarn/bin:$PATH"

You can remove the line after you uninstall yarn.

Source your profile file or restart your terminal after making the change.

shell
# BASH source ~/.bashrc source ~/.bash_profile # ZSH source ~/.zshrc source ~/.zprofile

If you need to install yarn on Windows, check out the following article.

# Uninstalling YARN on Linux

If you need to uninstall yarn on Ubuntu, open your terminal and run the following command.

shell
sudo apt-get remove yarn && sudo apt-get purge yarn

If the command above didn't work, try running the following command.

shell
sudo apt remove--autoremove yarn

If you are on CentOS, run the following command instead.

shell
sudo yum remove yarn

Check if yarn has been uninstalled.

shell
yarn --version

You can also run the which yarn command.

shell
which yarn

If yarn is still installed on your machine, use the rm -rf command to delete the folder you got from running which yarn.

For example, if your yarn directory is ~/.yarn, you would run the following command.

shell
rm -rf ~/.yarn

You might also have to run the npm uninstall -g yarn command.

shell
npm uninstall -g yarn

Make sure that the path to YARN has not been added to your ~/.bashrc, ~/.bash_profile or ~/.zshrc file.

For example, you might have the following line in your profile file.

~/.bashrc
export PATH="$HOME/.yarn/bin:$PATH"

You can remove the line after you uninstall yarn.

Source your profile file or restart your terminal after making the change.

shell
# BASH source ~/.bashrc source ~/.bash_profile # ZSH source ~/.zshrc source ~/.zprofile

If you need to install yarn on Linux, check out the following article.

# Uninstalling yarn with Corepack

If you used Corepack to install yarn, run the following command from your terminal.

shell
corepack disable yarn

If you get a permissions error when running the command on Windows, open CMD as an administrator and rerun the command.

To open CMD as an administrator:

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

  1. Rerun the command.
shell
corepack disable yarn

Verify that yarn is no longer installed.

shell
yarn --version

# Uninstall yarn from a project

If you've installed yarn in a specific project and want to uninstall it:

  1. Open your terminal in your project's root directory (where your package.json) file is and run the following command.
shell
npm uninstall yarn
  1. Delete your yarn.lock file from the root project folder.

If you are on macOS or Linux, you can remove the yarn.lock file by running the following command.

shell
rm -f yarn.lock

If you are on Windows, you can remove the file by running the following command in CMD.

cmd
del -f yarn.lock

After you run the command, clear your npm cache and rerun the npm install command.

shell
# 👇️ Clean your npm cache npm cache clean --force npm install

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.