博主
258
258
258
258
专辑

第三十一节 Vue无法下载依赖库的错误

亮子 2022-06-19 13:09:46 1119 0 0 0

故障现象:

git@github.com: Permission denied (publickey).

E:\code\vue-element-admin>npm install --registry=https://registry.npm.taobao.org
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/adobe-webplatform/eve.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\Think\AppData\Local\npm-cache\_logs\2022-06-19T12_49_22_372Z-debug-0.log

图片alt

解决方法:

第1步,查看本地账号

进入git bash界面然后:
第1步,git config --global --list 验证邮箱与GitHub注册时输入的是否一致。可以通过git config –global user.name “yourname”,git config --global user.email “email@email.com ”(这里得名字和邮箱都是注册github时用的)设置全局用户名和邮箱。

git config --global --list

图片alt

第2步,生成秘钥

使用 ssh-keygen -t rsa -C “这里换上你的邮箱”,**一路回车**,在出现选择时输入Y,再一路回车直到生成密钥。

ssh-keygen -t rsa -C 763906783@qq.com

图片alt

会在/Users/***/路径下生成一个.ssh文件夹,密钥就存储在其中:

图片alt

用文本工具打开id_rsa.pub文件,内容如下:

图片alt

第3步,使用浏览器到github仓库,添加秘钥

  • 复制公钥,在GitHub页面上点开自己的头像,进入Settings

图片alt

  • setting界面右边菜单选择SSH and GPG keys,选择新建SSH keys

图片alt

  • title可以自定,将复制的密钥粘贴到Key字段,最后选择Add SSH key成功添加

图片alt

图片alt

第4步,测试秘钥

使用 ssh -T git@github.com 测试一下通不通,通了显示如下

ssh -T git@github.com

图片alt

这时候你的问题就解决啦。

第5步,再次运行 npm install试试

npm install --registry=https://registry.npm.taobao.org

参考文章