当尝试通过 yarn install
使用 Yarn 安装我的项目的依赖项时,进程(和进度条指示器)在尝试获取包时挂起。永远不会发生超时,--verbose
选项没有提供有关问题原因的有用线索。
中央操作系统 7
yarn 版本:0.27.5
最佳答案
此问题是由 Yum 在 CentOS 上安装的旧版本 Git(撰写本文时为 1.8.3.1-6)和 Git 的双因素身份验证机制共同引起的。
Git 的 2FA 是挂起的首要原因,因为 Yarn 试图获取的其中一个包是通过 HTTPS ( see here for details ) 的私有(private)仓库。
事实证明,CentOS 中的 Git 客户端版本是挂起持续发生并且从未超时/出错的原因。也就是说,前面提到的 CentOS 上的 Git 版本阻止了 Yarn 识别身份验证错误并相应地退出。
解决方案是使用不同的存储库将 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
这将阻止 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
关于javascript - 为什么在 CentOS 上抓包时 `yarn install` 挂起?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45000746/