错误code128:npm ERR! An unknown git error occurred command git --no-replace-objects ls-remote ssh://

目录

一、遇到问题

二、出现问题的原因 

三、解决办法

四、类似的错误


一、遇到问题

在使用命令npm install下载依赖项的时候就遇到了这个问题,切换了国内的淘宝源也下载不了。

npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://[email protected]/nhn/raphael.git
npm ERR! [email protected]: 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!     D:\IT_base\node16\node_cache\_logs\2023-09-16T05_03_02_827Z-debug-0.log

二、出现问题的原因 

 git上面拉取东西时候出现了问题

三、解决办法

1.项目里面执行这个命令

git config --global url."https://".insteadOf ssh://git@

 这个命令的作用是将 Git 在使用 SSH 克隆(或拉取)仓库时的默认 URL 协议从 SSH 更改为 HTTPS。这是一个 Git 的配置设置,它可以对你的 Git 操作产生影响。

通常情况下,当你使用 SSH 协议克隆或拉取 Git 仓库时,URL 的格式是 ssh://[email protected]/username/repo.git,其中 [email protected] 是 SSH URL。但有时,你可能希望将 Git 操作重定向到使用 HTTPS 协议,例如 https://github.com/username/repo.git,这样可以避免 SSH 密钥的设置和管理。

使用 git config 命令设置 url."https://".insteadOf ssh://git@ 后,Git 将默认使用 HTTPS 协议而不是 SSH 协议来访问远程仓库,以便执行克隆、拉取等操作。这对于那些不想或不需要使用 SSH 密钥的情况非常有用。

注意,这个配置是全局配置,会影响你系统中的所有 Git 仓库。如果你只想在特定仓库中使用 HTTPS 协议,你可以在该仓库的 .git/config 文件中进行配置,而不是全局配置。

2.执行下载依赖项的命令

npm install

这样依赖项就下载成功了

四、类似的错误

解决npm install遇到的问题:Error while executing:_云边的快乐猫的博客-CSDN博客

猜你喜欢

转载自blog.csdn.net/m0_52861000/article/details/132917423
今日推荐