纱线:无法克隆私人 github 回购。 ssh:无法解析主机名 github:已提供节点名或服务名,或未知

Yarn: unable to clone private github repo. ssh: Could not resolve hostname github: nodename nor servname provided, or not known

我在 github 上有一个私人仓库,依赖于其他私人 github 仓库,npm install 安装所有依赖没有问题。

我安装了 Yarn(在 MacOS 上)并尝试在命令行中 运行 yarn,但克隆私有依赖项失败并出现以下错误:

ssh: Could not resolve hostname github: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

如何让 yarn 安装模块?谢谢!

目前 Yarn 不支持从 private package and private github repo

安装

有一个workaround provided by Milos Ivanovic:

If you add the following to your ~/.ssh/config file:

Host github.com
    User git 

you can force all logins to github.com via SSH to use the user git by >default, and this makes yarn able to clone from private repositories when using the ssh://github.com// source format.

幸运的是,yarn 在 github 上支持私人回购只是时间问题,因为它已经有了一个 pull request

Yarn@0.16.0 通过替换类型

的 url 来工作
"private-test": "git+ssh://git@github.com:ramasilveyra/private-test.git#d6c5789"

"private-test": "git+ssh://git@github.com/ramasilveyra/private-test.git#d6c5789"

: 冒号替换为 / 以使其生效。