npm ERR! code 128
npm ERR! An unknown git error occurred
PS D:\HT-Code\vue-element-admin> 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!
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\test\AppData\Local\npm-cache\_logs\2021-11-07T04_40_27_971Z-debug.log
这里我认为原因在这里:
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/nhn/raphael.git
在百度谷歌查了,很多重复的都是执行这两行命令
git config --global http.sslverify "false"
git config --global url."https://".insteadOf git://
两个我都试了没用,然后这看错误原因是和ssh和https有关,我去看了我的GitHub账号下的SSH Keys,啥都没有,然后创建一个SSH,添加到账号上,在NPM install就OK了,不过下的还是很慢哈。
然后创建ssh步骤是:
找到本地ssh文件夹:C:\user.ssh文件夹,然后在这个文件夹打开cmd,执行以下命令,替换你自己的邮箱,然后一路回车。
ssh-keygen -t rsa -C "your_email@example.com"
然后创建好后的ssh文件不能直接复制好像,我直接复制是添加不上去的,需要打开 git bash
输入命令cd ~/.ssh/id_rsa.pub
回车后就复制到剪切板了,到github添加ssh keys的地方直接就能粘贴上了
然后就🆗了;
参考文章:https://blog.csdn.net/qq_38230265/article/details/79108862?utm_source=app&app_version=4.5.8
本文档详细记录了解决npm安装过程中遇到的Git权限错误,特别是'git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.'的问题。通过检查SSH密钥、创建新的SSH key并将其添加到GitHub账户,最终成功解决该问题。同时,还介绍了如何生成和添加SSH key的步骤,包括在Windows环境下操作Git Bash来完成这一过程。

1万+

被折叠的 条评论
为什么被折叠?



