npm install 报错:code 128

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

  • 6
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值