当前位置:   article > 正文

npm install 报链接Github的错误,command git --no-replace-objects ls-remote ssh://git@github.com/nhn/raphael_npm install error command git --no-replace-objects

npm install error command git --no-replace-objects ls-remote ssh://git@githu

这是我的报错:

npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/nhn/raphael.git
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

这个错误信息表明在尝试通过 SSH 访问 GitHub 时遇到了权限问题。这通常是因为本地计算机没有正确配置 SSH 密钥,或者该密钥没有添加到 GitHub 账户中。解决这个问题的步骤如下:

  1. 检查 SSH 密钥:首先,需要确认你的计算机上是否已经有 SSH 密钥。安卓Git后桌面右击打开Git Bash:
ls -al ~/.ssh
  • 1
  1. 这会列出 .ssh 目录下的所有文件。通常,你会看到一对密钥文件,例如 id_rsa 和 id_rsa.pub(对于 RSA 密钥)。如果没有密钥,或者你想创建一个新的密钥对,可以使用以下命令:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  • 1

按照提示操作,可以设置密码或者直接按回车键跳过。

  1. 添加 SSH 密钥到 ssh-agent:确保 ssh-agent 在运行,并添加你的私钥到 ssh-agent。可以使用以下命令:
   eval "$(ssh-agent -s)"
   ssh-add ~/.ssh/id_rsa
  • 1
  • 2

如果你的密钥文件名不是默认的 id_rsa,请将命令中的 id_rsa 替换为实际的文件名。

  1. 将 SSH 公钥添加到 GitHub 账户:登录到你的 GitHub 账户,进入 Settings > SSH and GPG keys > New SSH key,将你的公钥(.pub 文件内容)粘贴到这里。公钥文件可以通过以下命令查看:
   cat ~/.ssh/id_rsa.pub
  • 1

复制输出的内容到 GitHub

完成这些步骤后,尝试再次运行你的命令。如果问题仍然存在,确认你的 package.json 或相关依赖配置是否正确指向了需要通过 SSH 访问的 Git 仓库。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/516168
推荐阅读
相关标签
  

闽ICP备14008679号