Estus Flask
Estus Flask

Reputation: 222309

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

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?

Upvotes: 12

Views: 25965

Answers (3)

am0wa
am0wa

Reputation: 8377

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)

Upvotes: 2

Estus Flask
Estus Flask

Reputation: 222309

The issue seems to be caused by the fact that there is no version field in package.json. While the fork that has no issue contains the field.

This was apparently a bug that was fixed in NPM 5.x.

Upvotes: 1

CodeWizard
CodeWizard

Reputation: 141946

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 :-)

Upvotes: 1

Related Questions