[node.js] How Do I Uninstall Yarn

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.

This question is related to node.js yarnpkg

The answer is


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


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)


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.


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


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


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


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.


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!


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.


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.


What I've done on my side:

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


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.


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.


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.


remove yarn

# macOS & brew
$ brew uninstall yarn


remove npm package

yarn global remove

# 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/


Incase 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.


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.


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>\)

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 

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


Questions with node.js tag:

Hide Signs that Meteor.js was Used Querying date field in MongoDB with Mongoose SyntaxError: Cannot use import statement outside a module Server Discovery And Monitoring engine is deprecated How to fix ReferenceError: primordials is not defined in node UnhandledPromiseRejectionWarning: This error originated either by throwing inside of an async function without a catch block dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac internal/modules/cjs/loader.js:582 throw err DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` jwt check if token expired Using Environment Variables with Vue.js Avoid "current URL string parser is deprecated" warning by setting useNewUrlParser to true Can not find module “@angular-devkit/build-angular” MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017] MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client npx command not found await is only valid in async function What could cause an error related to npm not being able to find a file? No contents in my node_modules subfolder. Why is that? How to set bot's status Returning data from Axios API Error: EACCES: permission denied, access '/usr/local/lib/node_modules' ReferenceError: fetch is not defined ERROR in Cannot find module 'node-sass' Test process.env with Jest 'react-scripts' is not recognized as an internal or external command NPM Install Error:Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0' db.collection is not a function when using MongoClient v3.0 When I run `npm install`, it returns with `ERR! code EINTEGRITY` (npm 5.3.0) E: Unable to locate package npm How can the default node version be set using NVM? How to downgrade Node version How to solve npm install throwing fsevents warning on non-MAC OS? How to read file with async/await properly? Angular: Cannot Get / The difference between "require(x)" and "import x" Is there a way to force npm to generate package-lock.json? Angular - ng: command not found MongoError: connect ECONNREFUSED 127.0.0.1:27017 How can I use async/await at the top level? ERROR in ./node_modules/css-loader? Downgrade npm to an older version Node - was compiled against a different Node.js version using NODE_MODULE_VERSION 51 npm install Error: rollbackFailedOptional npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY How can I use an ES6 import in Node.js? Node.js: Python not found exception due to node-sass and node-gyp bash: npm: command not found? npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Nuwanst\package.json' Laravel 5.4 ‘cross-env’ Is Not Recognized as an Internal or External Command

Questions with yarnpkg tag:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined raised when starting react app Module not found: Error: Can't resolve 'core-js/es6' Yarn: How to upgrade yarn version using terminal? Yarn install command error No such file or directory: 'install' How to install package from github repo in Yarn How Do I Uninstall Yarn How to clear cache in Yarn?