当前位置: 代码迷 >> 综合 >> 解决前端项目 npm install 时报错:Could not read from remote repository.
  详细解决方案

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

热度:89   发布时间:2023-10-26 10:51:14.0

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

  相关解决方案