node.js 如何卸载 Yarn

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42334978/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:01:07  来源:igfitidea点击:

How Do I Uninstall Yarn

node.jsyarnpkg

提问by maxwellgover

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.jsor index.android.jsit 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 yarnbut that didn't work. Thanks.

如何卸载纱线?我已经将它用于本机项目,现在每当我将代码移出index.ios.jsindex.android.js抛出错误时,我只想使用 npm 但每当我初始化本机项目时,它默认为纱线。我试过了,npm uninstall yarn但这没有用。谢谢。

回答by sospedra

Depends on how you installed it:

取决于您如何安装它

brew: brew uninstall yarn

酿造brew uninstall yarn

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

压缩包rm -rf "$HOME/.yarn"

npm: npm uninstall -g yarn

纳米npm uninstall -g yarn

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

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

centos: yum remove yarn

中心yum remove yarn

windows: choco uninstall yarn

窗户choco uninstall yarn

回答by Jan Jar?ík

I'm using macOSand only that worked for me:

我正在使用macOS,只有它对有用

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

v0.24.5 (or your current version)

v0.24.5(或您当前的版本)

$ which yarn

/usr/local/bin/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)

v1.17.3(最新版本)

回答by elthrasher

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 ~/.yarntook care of it.

没有看到对我有用的答案,所以这里是:在我的 OSX 系统上,我在~/.yarn/bin/yarn. rm -rf ~/.yarn照顾它。

回答by Alireza Fattahi

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

在 Windows 上:转到控制面板中的“添加或删除程序”(或打开开始菜单并搜索“删除程序”)

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

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

回答by john-prodlabs

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

如果您使用 brew 安装,请brew uninstall yarn在终端提示符下尝试。还记得在你的.bash_profile.

回答by Luke Schoen

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

我正在使用 macOS。我在 Homebrew 上安装了几个版本的纱线,我用brew uninstall --force yarn. 然后我使用 Homebrew 安装了最新版本的 Yarn 1.7.0brew install yarn

But still when I ran which yarn, it returned /Users/Me/.yarn/bin/yarn, and yarn --versionreturned 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.

但是当我运行时which yarn,它返回 /Users/Me/.yarn/bin/yarn,并yarn --version返回 0.24.6。~/.bash_profile 中没有提到 Yarn,但我的 ~/.bashrc 文件包含的行export PATH="$HOME/.yarn/bin:$PATH"表明我之前必须全局安装 Yarn,但我只想使用我刚刚用 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 ~/.bashrcto update the PATH in the terminal session. Then when I ran which yarnit returned /usr/local/bin/yarn, and when I ran yarn --versionit returned 1.7.0

因此,我通过运行全局卸载 Yarn npm uninstall -g yarn; rm -rf ~/.yarn,然后通过将行更改为export PATH="/usr/local/bin/yarn:$PATH"并运行source ~/.bashrc来编辑文件 ~/.bashrc以更新终端会话中的 PATH。然后当我运行which yarn它返回/usr/local/bin/yarn,当我运行yarn --version它返回1.7.0

回答by mbd

I tried the Homebrewand tarballpoints from the post by sospedra. It wasn't enough.

我尝试了sospedra 帖子中Homebrewtarball点。这还不够。

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

我发现纱线安装在: ~/.config/yarn/global/node_modules/yarn

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

我跑了yarn global remove yarn。重新启动终端,它消失了。

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.

本来,我来这里的原因是yarn恢复到旧版本,但我不知道为什么,尝试卸载或升级失败。

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

当我将签出一定的项目中使用的纱线的版本将从改变旧的分支1.9.40.19.1

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

即使在采取措施去除纱线后,它仍然存在,并且处于0.19.1.

回答by Edmundo Rodrigues

What I've done on my side:

我在我这边做了什么:

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

转到/usr/local/lib/node_modules,并删除其中的yarn文件夹。

回答by Alexander Cherednichenko

In case you installed yarnglobally 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!

现在在我运行 Ubuntu 的本地机器上测试。工作完美!

回答by Raja Rahul

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.

npm uninstall yarn 删除通过 npm 安装的 yarn 包,但 yarn 在引擎盖下的作用是,它会在您的 PC 中安装一个名为 yarn 的软件。如果您已在 Windows 中安装,请转到添加或删除程序,然后搜索 yarn 并卸载它,然后您就可以开始了。