解决前端项目 npm install 时报错:Could not read from remote repository.

本文详细介绍了在使用npm install过程中遇到的Git错误128,重点在于如何通过设置SSH连接解决无法从GitHub远程仓库读取的问题,包括生成并配置SSH密钥对的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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! Connection reset by 20.205.243.166 port 22
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.

原因:无法从 github 远程存储库中读取

解决方案:设置好本地通过 ssh 方式连接上 github

# git bash
$ cd ~/.ssh
$ ssh-keygen -t rsa -C "github 邮箱"
# 一直回车,直至生成公钥与私钥文件
# Your identification has been saved in /c/Users/shuang/.ssh/id_rsa
# Your public key has been saved in /c/Users/shuang/.ssh/id_rsa.pub
$ ls
$ cat id_rsa.pub
# 复制公钥信息添加到 github SSH keys 配置中

# 测试 github 连接
$ ssh -T git@github.com
# Hi 用户名! You've successfully authenticated, but GitHub does not provide shell access.

image-20211023231732828

image-20211023231500714

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值