Table of contents
1. Encountering problems
I encountered this problem when using the command npm install to download dependencies. Even if I switched to the domestic Taobao source, I could not download it.
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
2. Causes of problems
There was a problem when pulling things on git
3. Solution
1. Execute this command in the project
git config --global url."https://".insteadOf ssh://git@
The purpose of this command is to change Git's default URL protocol when cloning (or pulling) a repository using SSH from SSH to HTTPS. This is a Git configuration setting that can have an impact on your Git operations.
Normally, when you use the SSH protocol to clone or pull a Git repository, the format of the URL is
ssh://[email protected]/username/repo.git
, where[email protected]
is the SSH URL. But sometimes, you may want to redirect Git operations to use the HTTPS protocol, for examplehttps://github.com/username/repo.git
, to avoid the setup and management of SSH keys.After using
git config
the command settingurl."https://".insteadOf ssh://git@
, Git will use the HTTPS protocol instead of the SSH protocol by default to access the remote repository to perform operations such as cloning and pulling. This is useful for situations where you don't want or need to use SSH keys.Note that this configuration is a global configuration and will affect all Git repositories in your system. If you only want to use the HTTPS protocol in a specific repository, you can
.git/config
configure it in the repository's file instead of configuring it globally.
2. Execute the command to download dependencies
npm install
In this way, the dependencies are downloaded successfully.