如何卸载纱线?我已经将它用于一个react-native项目,现在每当我将代码移出index.ios.js或index.android.js时,它都会抛出一个错误,所以我只想使用npm,但每当我初始化一个react-native项目时,它默认为yarn。我尝试了npm卸载yarn,但没有工作。谢谢。


当前回答

如果你正在使用corepack,并且之前运行了corepack enable命令,那么你可以通过以下命令卸载yarn:

corepack disable yarn

其他回答

在我的Mac上,这两种常规方法都不能卸载Yarn:

酿造:酿造卸载纱线

Npm: Npm卸载-g yarn

相反,我手动删除它输入rm -rf ~/。Yarn(感谢用户elthrasher)并删除usr/local/bin中的Yarn和yarnpkg两个符号。 之后酝酿安装yarn给了我最新版本的yarn。


背景:事实上,我安装了一个非常过时的Yarn版本,当我试图安装额外的模块到一个用Vue CLI Service和Vue UI设置的项目时,我犯了完全无法理解的错误,而Vue CLI Service和Vue UI显然在“底层”使用了Yarn。我通常使用NPM,所以我花了一段时间来找出我的问题的原因。当然,谷歌这种模块不兼容所产生的错误消息并没有提供任何线索。随着Yarn的更新,现在一切都很完美。

如果你是用npm安装的,试试"npm uninstall -g yarnpkg"(global)或者"npm uninstall yarnpkg"(local)。 这对我来说很有效。 如果仍然不工作,你安装了npm,执行"npm list -g"检查是否全局安装,或"npm list"检查是否本地安装。希望这对有这个问题的人有所帮助。: D

编辑:发现一些东西,如果你安装yarn .msi可执行文件,你必须安装正常的windows方式。

windows:在控制面板中选择“添加或删除程序”(或打开开始菜单,搜索“删除程序”)

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

如果你像这样在全球安装纱线

$ sudo npm install -g yarn

在终端中运行即可

$ sudo npm uninstall -g yarn

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

Windows:

我需要做这些步骤,以完全去除纱线从系统。

Go to add or remove programs and then search for yarn and uninstall it(if you installed it with the .msi) npm uninstall -g yarn (if you installed with npm) Remove any existing yarn folders from your Program Files (x86) (Program Files (x86)\Yarn). 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) Finally,check your user directory and remove all .yarn folder, .yarn.lock file, .yarnrc etc ( from C:\Users\<user>\)