How To Uninstall Yarn?

2.7K    Asked by Amitraj in SQL Server , Asked on Nov 17, 2022

I had installed Yarn for some demo. Now I am trying to run a react project using npm but by default, it always changes to Yarn. I don't need Yarn now, so I want to uninstall it. I tried the following command but it did not work: sudo apt-get remove yarn && sudo apt-get purge yarn

How can I uninstall Yarn?

Answered by Amit raj
To uninstall yarn -
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


Your Answer

Answer (1)

Uninstalling Yarn depends on how you installed it. Below are different methods based on your installation type.

Uninstalling Yarn Based on Installation Method

1. If Installed via npm

If you installed Yarn using npm, you can remove it with:

  npm uninstall -g yarn

  • This removes Yarn globally from your system.

To confirm it’s uninstalled, run:

  yarn --version

If the command is not found, it’s successfully removed.

2. If Installed via Homebrew (macOS/Linux)

For macOS and Linux users who installed Yarn via Homebrew, use:

  brew uninstall yarn

If you want to remove all dependencies, run:

  brew cleanup

3. If Installed via Chocolatey (Windows)

For Windows users who installed Yarn using Chocolatey, remove it with:

  choco uninstall yarn

4. If Installed via the Yarn Installer

If you installed Yarn via the standalone installer:

  • Manually delete Yarn from your system’s installation directory (usually in C:Program Files (x86)Yarn on Windows or /usr/local/bin/yarn on Linux/macOS).

Final Checks

After uninstallation, verify it's removed by running:

  yarn --version

If you get an error like "command not found," Yarn is successfully uninstalled.


2 Weeks

Interviews

Parent Categories