9

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 git@github.com: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?

Estus Flask
  • 206,104
  • 70
  • 425
  • 565
  • This also happens when you're supposed to be doing npm install -g @angular/cli and you leave off the @ – Warren P Apr 26 '20 at 22:44

3 Answers3

3

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

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • 1
    But why are all other repos working well? Have you tried the repo I've suggested as a trouble-maker? This problem is also persists on web server, and I would prefer to not leave my key there at all. This defies the purpose of NPM as hassle-free installation tool. – Estus Flask Apr 12 '17 at 04:43
3

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)
am0wa
  • 7,724
  • 3
  • 38
  • 33
  • This is what is usually suggested in other questions with same error, and this usually works. This case was different. As the question says, this happened for *public* repo. – Estus Flask Jul 21 '17 at 12:37
0

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.

Estus Flask
  • 206,104
  • 70
  • 425
  • 565
  • this isn't a fix, what if you *want* to use a git url, but with http, not ssh? – Wes Oct 15 '21 at 20:13
  • If you want to use another protocol, you can specify it explicitly, `npm i https://github.com/InfomediaLtd/angular2-materialize`. If this is what you looked for then you downvoted a wrong post, because this one is unrelated. This is an explanation for the described problem, the protocol was never a part of it, you could check it yourself. Any way, the problem here is exactly what I mentioned, npm fails regardless of protocol because of malformed package.json, but current version provides meaningful output at least. – Estus Flask Oct 15 '21 at 23:38