当前位置:   article > 正文

npm install 时报 npm ERR command git --no-replace-objects ls-remote ssh_npm err! an unknown git error occurred npm err! co

npm err! an unknown git error occurred npm err! command git --no-replace-obj
PS D:\code\www\4.0_backview> 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! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\pc\AppData\Local\npm-cache\_logs\2022-01-19T01_46_52_518Z-debug.log
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

操作一: 检查.gitconfig文件
win10一般在: /c/Users/pc/.gitconfig
在最底部添加:

# 将git://的都替换成https
[url "https://github.com/nhn/raphael.git/"]
insteadOf = git://github.com/nhn/raphael.git/
  • 1
  • 2
  • 3

再次npm install , 无果, 再看操作二

操作二: github添加ssh

ssh-keygen -t rsa -b 2048 -C "你自己的邮箱地址"
# 回车后如果你需要填写多个ssh, 则直接写绝对路径, eg: /c/Users/pc/.ssh/github_id_rsa, 防止与gitee有相冲突的文件
cat ~/..sh/github_id_rsa.pub
# 复制到github ssh
  • 1
  • 2
  • 3
  • 4

在这里插入图片描述

再试一试
出现443的, 再跑多几次就好了, 已经不是上面出现的问题点了, 只是国内网络连通的问题, 你懂的~

PS D:\code\www\4.0_backview> npm install --registry=https://registry.npm.taobao.org
npm ERR! code 128
npm ERR! A git connection error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/nhn/raphael.git
npm ERR! fatal: unable to access 'https://github.com/nhn/raphael.git/': Failed to connect to github.com port 443: Timed out
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\pc\AppData\Local\npm-cache\_logs\2022-01-19T02_11_27_611Z-debug.log
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/516219
推荐阅读
相关标签
  

闽ICP备14008679号