Last updated: Apr 4, 2024
Reading time·5 min
If you've installed yarn
using npm
, you can uninstall it by running the
npm uninstall -g yarn
command in your terminal.
npm uninstall -g yarn
If you get a permissions error on macOS or Linux, try to rerun the command
prefixed with sudo
.
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:
Click on the Search bar and type CMD.
Right-click on the Command Prompt application and click "Run as administrator".
npm uninstall -g yarn
You can check if yarn
has been uninstalled by issuing the yarn --version
command.
yarn --version
If that doesn't work, follow the operating system-specific instructions on how
to uninstall yarn
.
If you installed yarn
on Windows using Chocolatey, to uninstall the package:
Click on the Search bar and type "PowerShell".
Right-click on the "PowerShell" application and click "Run as administrator".
yarn
.choco uninstall yarn -y
Otherwise, to uninstall yarn
on Windows:
Select Add or remove programs from the list of options.
Either search for yarn
or scroll down until you find the yarn
program.
After you uninstall yarn
issue the yarn --version
command to verify.
yarn --version
You might also have to run the npm uninstall -g yarn
command.
npm uninstall -g yarn
To uninstall yarn
on macOS, run the following command from your terminal.
brew uninstall --force yarn
You might also have to run the following command.
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.
which yarn
You might also have to delete the yarn
directory manually from your terminal.
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.
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.
yarn --version
If you need to reinstall yarn
, run the following commands.
brew install yarn brew link yarn
Verify that yarn
is installed.
yarn --version
You can also install yarn
using npm
.
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.
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.
# BASH source ~/.bashrc source ~/.bash_profile # ZSH source ~/.zshrc source ~/.zprofile
If you need to install yarn
on Windows, check out the
following article.
If you need to uninstall yarn
on Ubuntu, open your terminal and run the
following command.
sudo apt-get remove yarn && sudo apt-get purge yarn
If the command above didn't work, try running the following command.
sudo apt remove--autoremove yarn
If you are on CentOS, run the following command instead.
sudo yum remove yarn
Check if yarn
has been uninstalled.
yarn --version
You can also run the which yarn
command.
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.
rm -rf ~/.yarn
You might also have to run the npm uninstall -g yarn
command.
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.
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.
# BASH source ~/.bashrc source ~/.bash_profile # ZSH source ~/.zshrc source ~/.zprofile
If you need to install yarn
on Linux, check out the
following article.
If you used Corepack to install yarn, run the following command from your terminal.
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:
Click on the Search bar and type CMD.
Right-click on the Command Prompt application and click "Run as administrator".
corepack disable yarn
Verify that yarn
is no longer installed.
yarn --version
If you've installed yarn in a specific project and want to uninstall it:
package.json
) file is and run the following command.npm uninstall yarn
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.
rm -f yarn.lock
If you are on Windows, you can remove the file by running the following command in CMD.
del -f yarn.lock
After you run the command, clear your npm
cache and rerun the npm install
command.
# 👇️ Clean your npm cache npm cache clean --force npm install
You can learn more about the related topics by checking out the following tutorials: