简体   繁体   English

为什么在 CentOS 上获取软件包时 `yarn install` 会挂起?

[英]Why does `yarn install` hang when fetching packages on CentOS?

When attempting to install the dependencies for my project with Yarn via yarn install , the process (and progress bar indicator) hangs when attempting to fetch packages.当尝试通过yarn install为我的项目安装依赖项时,进程(和进度条指示器)在尝试获取包时挂起。 A timeout never occurs and the --verbose option gives no useful clues regarding the cause of the problem.永远不会发生超时,并且--verbose选项没有提供有关问题原因的有用线索。

CentOS 7 CentOS 7

Yarn version: 0.27.5纱线版本:0.27.5

This issue is caused by the combination of the older version of Git installed by Yum on CentOS (1.8.3.1-6 at the time of this writing) and Git's two-factor authentication mechanism.这个问题是由 Yum 在 CentOS 上安装的旧版 Git(在撰写本文时为 1.8.3.1-6)和 Git 的双因素身份验证机制的结合造成的。

Git's 2FA is the reason the hanging occurs in the first place, since one of the packages Yarn was attempting to fetch was a private repo via HTTPS ( see here for details ). Git 的 2FA 是首先发生挂起的原因,因为 Yarn 试图获取的包之一是通过 HTTPS 的私有存储库( 有关详细信息,请参见此处)。

The version of the Git client in CentOS turned out to be the reason the hanging continued to occur and never timed / erred out. CentOS 中 Git 客户端的版本原来是挂起继续发生并且从未超时/错误的原因。 That is, the aforementioned version of Git on CentOS prevented Yarn from recognizing the authentication error and exiting accordingly.也就是说,上述 CentOS 上的 Git 版本阻止 Yarn 识别身份验证错误并相应地退出。

The solution is to upgrade Git to a more recent version using a different repo:解决方案是使用不同的 repo 将 Git 升级到更新的版本:

sudo yum -y erase git
sudo rpm -U http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm
sudo yum -y install git

This will stop Yarn from continuing to hang, with an output similar to the following:这将阻止 Yarn 继续挂起,输出类似于以下内容:

[1/4] Resolving packages...
[2/4] Fetching packages...
error Command failed.
Exit code: 128
Command: git
...
fatal: could not read Username for 'https://github.com': terminal prompts disabled

My coworker and I had a similar issue and it was hanging because the vpn had disconnected.我和我的同事遇到了类似的问题,由于 vpn 断开连接而挂起。 So double check your vpn is connected.因此,请仔细检查您的 vpn 是否已连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM