vue-element-admin npm install 报错

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! no such identity: /c/Users/masterlin/.ssh/github_id_rsa: No such file or directory
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\masterlin\AppData\Local\npm-cache\_logs\2022-01-03T09_29_27_844Z-debug-0.log
no such identity: /c/Users/masterlin/.ssh/github_id_rsa: No such file or directory 

没有.ssh/github_id_rsa文件。

找到ssh文件夹:"C:\Users\masterlin.ssh"文件夹,然后在这个文件夹打开cmd,执行以下命令,替换你自己的邮箱

ssh -keygen -t rsa -C "your_email@example.com"

回车

输入密码

再次确认密码

然后生成github,的公钥id_rsa.pub和私钥id_rsa
vue-element-admin npm install 报错

将公钥添加到github的ssh keys上。

再次运行npm install

还是出错,在细看

原来生成的公钥文件名为id_rsa.pub,而项目需要的文件名为github_id_rsa。

改名后,再次运行 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/adobe-webplatform/eve.git
npm ERR! Load key "/c/Users/masterlin/.ssh/github_id_rsa": invalid format
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\masterlin\AppData\Local\npm-cache\_logs\2022-01-03T09_37_54_026Z-debug-0.log
Load key "/c/Users/masterlin/.ssh/github_id_rsa": invalid format

这次不在是文件不存在,而是文件格式不正确

再次查找问题,最后是生成的公钥的格式是新格式

强制 openSSH 生成旧格式:

ssh-keygen -m PEM -t rsa -P "" -f filename

现在使用命令 ssh-keygen -t rsa 生成ssh,默认是以新的格式生成,id_rsa的第一行变成了“BEGIN OPENSSH PRIVATE KEY” 而不在是“BEGIN RSA PRIVATE KEY”

最后换成旧格式,

npm install 成功下载依赖,

npm run dev 成功运行项目

上一篇:「IOI2021」分糖果


下一篇:SQL Server 默认跟踪应用1 -- 删除对象事件