Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Could not read from remote repository' on NPM install from GitHub public repo

Tags:

git

github

npm

I have problems installing some NPM packages. This happens when NPM package (angular2-materialize for example) is installed from the repo:

npm i InfomediaLtd/angular2-materialize

Also happens with its forks, too. I've tried to to create own forks with same results.

Installing it results in error,

 Error: Command failed: git -c core.longpaths=true clone --template=<...>\npm-cache\_git-remotes\_templates --mirror [email protected]:InfomediaLtd/angular2-materialize.git <...>\npm-cache\_git-remotes\git-github-com-InfomediaLtd-angular2-materialize-git-2ec1a411
 Cloning into bare repository '<...>\npm-cache\_git-remotes\git-github-com-InfomediaLtd-angular2-materialize-git-2ec1a411'...
 Host key verification failed.
 fatal: Could not read from remote repository.

 Please make sure you have the correct access rights
 and the repository exists.

The repo is public, it surely exists and can be cloned with

git clone git://github.com/InfomediaLtd/angular2-materialize.git

On the other hand, there's no error on this fork (repo name has been changed):

npm i thcheng/angular-plus-materialize

And other repos can be installed without problems as well:

npm i toddmotto/angular-component

I've tried this with all NPM versions on Windows, also tried this on Ubuntu server with same results. I run NPM as admin/root and tried to clean NPM cache (as relevant questions usually suggest).

Is there something wrong with this repo in particular? What is going on there and how can this be fixed?

like image 574
Estus Flask Avatar asked Apr 12 '17 04:04

Estus Flask


People also ask

Could not read from remote repository npm install?

You may encounter this error when installing npm. This happens when you list a git repository as a dependency in your package. json file. If the repository is private, add an additional SSH key in Project settings > SSH Keys > Additional SSH Keys.

Does npm download from GitHub?

The npm installation from GitHub is quite useful for testing packages. It also gives the flexibility to install any specific branch, version, tag, and so on.

How do I add an npm link to GitHub?

Add the GitHub repository URL there: "repository": { "type": "git", "url": "https://github.com/your-user/repo-url.git" }, Make sure you specify git as type and that the URL is pointing to the actual repository, not an HTML page. So the URL has to end with .


2 Answers

You don't have ssh key on your machine.

if you wish to clone it without ssh key use the https method instead of the git ://


How to add ssh key to github account?

  • Generate a new ssh key (or skip this step if you already have a key)
    ssh-keygen

  • Get the key
    cat ~/.ssh/id_rsa.pub

  • Login to github account

  • Click on the rancher on the top right (Settings)
    github account settigns

  • Click on the SSH keys
    ssh key section

  • Click on the Add ssh key
    Add ssh key

  • Paste your key and save

And you all set to go :-)

like image 166
CodeWizard Avatar answered Oct 24 '22 23:10

CodeWizard


Configure the ssh-agent program to use your SSH key:

Make sure your id_rsa file is in the folder c:\users\$username\.ssh

Open console and run start-ssh-agent. It will find your id_rsa and prompt you for the passphrase:

start-ssh-agent
Removing old ssh-agent sockets
Starting ssh-agent:  done
Enter passphrase for /c/Users/youruser/.ssh/id_rsa:
Identity added: /c/Users/youruser/.ssh/id_rsa (/c/Users/youruser/.ssh/id_rsa)

Then try to run npm install again.


Note: It's also might be possible that ssh-agent is already running:

start-ssh-agent
Found ssh-agent at 402860
Found ssh-agent socket at /tmp/ssh-YT2trepckpeN/agent.431360

In this case use ssh-add It will find your id_rsa and prompt you for the passphrase:

ssh-add
Enter passphrase for /c/Users/youruser/.ssh/id_rsa:
Identity added: /c/Users/youruser/.ssh/id_rsa (/c/Users/youruser/.ssh/id_rsa)
like image 41
am0wa Avatar answered Oct 25 '22 00:10

am0wa