npm ERR code 128npm ERR An unknown git error occurrednpm ERR command git --no-replace-objects l

安装 npm install时的错误提示

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! Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR! and the repository exists.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\nodejs\node_cache\_logs\2022-04-27T08_23_27_820Z-debug-0.log

尝试了很多种方法比如:npm cache clean --force

然后再:npm install

反正都是错误的

然后看了另外一个大佬的博文最终成功解决问题 

第一步:在你的电脑上 的开始里面找到一个Git文件夹,然后打开Git Bush,或者直接在桌面右键找到Git Bush here,打开

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

 ··0a0f459b103a46fdb2172efa6ba24cfb.png

 之后你的c盘->用户->你的用户名->.ssh文件中会生成两个新的文件,一个叫id_rsa.pub

另一个是id_rsa,打开id_rsa.pub文件。id_rsa.pub就是你的新公钥,全选复制里面的内容,最后填充到最下面那张图里面的KEY中就行了

 0fb2e5b83f8c42d8acc6a0fe270d567f.png

然后再打开GitHub网站找到右上角你的账户,在找到settings

 76e17514db65447088e62e7c1aae090b.png 

 f5e7ee7a938f4db2a3a67f41bc73df49.png

最后 425ddd42ac854ba28b8a4937f7b9d210.png

最后重新安装依赖就OK了 

最后链接了远程仓库后发现无法push上去,报错信息:

ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.        

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

这是因为 GitHub 已切换到端口 443:自2021年起,GitHub 默认推荐使用 SSH over the HTTPS port (443) 来替代原生的SSH端口22。如果你之前是基于旧版设置,需要更新你的 ~/.ssh/config 文件以指向新的端口(如果适用)。

~/.ssh/config中的'~'其实就是代表你的用户名目录

如果没有config这个文件就新建一个config文件,注意没有后缀名,并把下面的信息复制进去:

Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

  • 14
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

H-rosy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值