Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

npm

yarnpkg

I have a private repo on github with dependencies on other private github repos and npm install installs all the dependencies without problems.

I installed Yarn (on MacOS) and tried to run yarn in the command line, but it failed cloning the private dependencies with the following error:

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

How do I make yarn install the modules? Thanks!

like image 423
Spadar Shut Avatar asked Oct 13 '16 08:10

Spadar Shut


2 Answers

[email protected] works by replacing the url of type

"private-test": "git+ssh://[email protected]:ramasilveyra/private-test.git#d6c5789"

with

"private-test": "git+ssh://[email protected]/ramasilveyra/private-test.git#d6c5789"

Replace : colon with / to make it work.

like image 73
Santosh Avatar answered Jan 04 '23 03:01

Santosh


For now Yarn doesn't support installation from private package and private github repo

There is a 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.

Fortunately this is just a matter of time before yarn support private repo on github, as there is already a pull request for it.

like image 26
YasserKaddour Avatar answered Jan 04 '23 05:01

YasserKaddour