How to fix npm ERR! git clone git://github.com/user/repo.git failed npm ERR! fatal: repository not found in npm
This error occurs when npm attempts to clone a git repository during dependency installation but git cannot locate the repository at the specified URL. This suggests either the URL is wrong, the repository doesn't exist, or you lack permissions.
Quick fix
Fixes npm ERR! git clone git://github.com/user/repo.git failed npm ERR! fatal: repository not found
git clone https://github.com/OWNER/REPO.git- Verify the repository URL format
- Verify the repository actually exists
- Test authentication with git directly
- Fix authentication for private repositories
git clone https://github.com/OWNER/REPO.gitnpm ERR! git clone git://github.com/user/repo.git failednpm ERR! fatal: repository not found
What this error means
This error occurs when npm attempts to clone a git repository during dependency installation but git cannot locate the repository at the specified URL. Unlike authentication errors, this suggests either: 1. The URL is wrong (typos, incorrect format) 2. The repository doesn't exist at that location 3. You lack sufficient permissions to see the repository (which git treats as "not found") Important: Git hosting platforms like GitHub intentionally return "not found" for private repositories you can't access, to avoid leaking information about which private repositories exist. This means "repository not found" often actually means "permission denied" for private repos.
Typical symptoms
- npm install fails with 'fatal: repository not found'
- Error appears when installing dependencies from git repositories
- Works on some machines but fails on others
- CI/CD pipelines fail at dependency installation step
- Private repositories fail but same URL works with manual git clone
Common causes
- Invalid or malformed URL in package.json (typos, incorrect format)
- Repository deleted or renamed
- Case sensitivity mismatch in repository name
- Missing .git extension (some hosts require it)
- Incorrect Git protocol (git:// blocked by firewall)
- Permission denied appearing as 'Not Found' for security
- Wrong SSH key or SSH configuration
- Cached invalid credentials preventing authentication
How to fix "npm ERR! git clone git://github.com/user/repo.git failed npm ERR! fatal: repository not found"
Check your package.json and verify the git URL is correct:
Valid formats:
- GitHub: https://github.com/OWNER/REPO or git+https://github.com/OWNER/REPO.git
- SSH: git+ssh://git@github.com/OWNER/REPO.git
- Shorthand: github:OWNER/REPO
Invalid formats (remove if present):
- https://github.com/OWNER/REPO/tree/main (branch reference for UI, not git)
- git://github.com/OWNER/REPO (git:// protocol may be blocked)
Check exact capitalization and spelling.
Visit the repository URL in a web browser to confirm:
- The repository exists and hasn't been deleted
- You can access it (may require login for private repos)
- The owner and repository names are spelled correctly
For GitHub: https://github.com/OWNER/REPO
Check the exact capitalization against the URL in your package.json.
Try cloning the repository manually:
git clone https://github.com/OWNER/REPO.gitIf this succeeds, the issue is npm-specific.
If this fails with "repository not found", it's a git/authentication issue.
For SSH URLs:
ssh -T git@github.comThis should respond with "Hi username! You've successfully authenticated."
Private repositories require proper authentication:
Option A: Use Personal Access Token (HTTPS)
{
"dependencies": {
"my-package": "git+https://TOKEN:x-oauth-basic@github.com/OWNER/REPO.git"
}
}Option B: Use SSH with Deploy Keys
1. Add an SSH key as a deploy key in repository settings
2. Configure ~/.ssh/config
3. Update package.json:
{
"dependencies": {
"my-package": "git+ssh://git@github.com/OWNER/REPO.git"
}
}Outdated cached credentials can cause "repository not found" errors:
Windows:
1. Open Control Panel > Credential Manager
2. Find entries for github.com
3. Delete git-related credentials
4. Run npm install again
macOS:
1. Open Keychain Access
2. Search for "github"
3. Delete expired/incorrect credentials
Linux:
git config --global --unset credential.helperIf git:// URLs fail but https:// works, configure git to use HTTPS:
git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://Update package.json to use explicit git+https://.
Advanced notes
Authentication vs. Authorization: Git distinguishes between "I can't authenticate you" (403) and "the repository doesn't exist" (404). GitHub returns 404 for private repositories you can't access to avoid leaking information about which private repos exist.
Git Protocol Trade-offs:
- git:// - Fastest, read-only, often blocked by firewalls
- ssh:// - Requires SSH key setup, works in restricted networks
- https:// - Works everywhere, supports token authentication
Repository Case Sensitivity: GitHub treats repository names as case-insensitive in URLs but returns the exact case. Always verify the exact capitalization.
Frequently asked questions
- What does "npm ERR! git clone git://github.com/user/repo.git failed npm ERR! fata" mean?
- This error occurs when npm attempts to clone a git repository during dependency installation but git cannot locate the repository at the specified URL. Unlike authentication errors, this suggests either: 1. The URL is wrong (typos, incorrect format) 2.
- How do I fix "npm ERR! git clone git://github.com/user/repo.git failed npm ERR! fata"?
- This error occurs when npm attempts to clone a git repository during dependency installation but git cannot locate the repository at the specified URL. This suggests either the URL is wrong, the repository doesn't exist, or you lack permissions.
- What causes "npm ERR! git clone git://github.com/user/repo.git failed npm ERR! fata"?
- Invalid or malformed URL in package.json (typos, incorrect format) Repository deleted or renamed Case sensitivity mismatch in repository name
- Is the "npm ERR! git clone git://github.com/user/repo.git failed npm ERR! fata" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐npm Official Documentation
- ๐npm Docs: install command(Official Docs)
- ๐ฌStack Overflow: npm git dependencies(Stack Overflow)
- ๐