AI Diagnostic Summary

npm ERR! code ENOGIT

Well-Documented Error

This error matches known, documented patterns with reliable solutions.

Quick Fix (Most Common Solution)

Seeing "npm ERR! code ENOGIT"? This error can be frustrating, but it's usually fixable. It typically affects your development workflow or system. Below you'll find clear, step-by-step solutions to resolve this issue.

High confidence
What This Error Means

A package requires git clone but git is not installed.

Frequently documented in developer and vendor support forums.

Based on documented solutions and common real-world fixes.
Not affiliated with browser, OS, or device manufacturers.

New here? Learn why exact error messages matter →

Common Causes
  • Git not installed
  • Git not in PATH
  • Git dependency in package
How to Fix
  1. Install git
  2. Add git to system PATH
  3. Use https instead of git URLs

Last reviewed: March 2026 How we review solutions

Why This Happens

ENOGIT means npm tried to execute a git command but could not find the git binary on your system PATH. npm needs git for several operations: installing packages directly from Git repositories (npm install github:user/repo), resolving dependencies that point to Git URLs in package.json, running prepare scripts that call git, and processing package-lock.json entries that reference Git commit hashes. The most common scenario is a clean CI/CD environment or Docker container that does not include git in its base image—official Node.js Docker images include npm but not git, and many minimal CI runners follow the same pattern. Development machines almost always have git installed, so this error primarily appears in automated environments. Windows users occasionally encounter ENOGIT when git is installed but not added to the system PATH—the Git for Windows installer offers a choice between adding git to PATH or keeping it isolated, and choosing the isolated option makes git invisible to npm. Another subtle cause is package.json dependencies that use the git+https:// or git+ssh:// protocol specifiers, which are common in enterprise projects using private Git repositories instead of private npm registries.

Quick Diagnostic Checklist
  1. Check if git is installed: git --version
  2. If not installed: apt install git (Linux), brew install git (macOS)
  3. On Windows: reinstall Git for Windows and select "Git from the command line"
  4. In Docker: add RUN apt-get update && apt-get install -y git to your Dockerfile
  5. Check if the dependency uses a git URL: grep "git+" package.json
Resolving ENOGIT in Docker and CI environments
# Error output:
# npm ERR! code ENOGIT
# npm ERR! Error while executing:
# npm ERR! /usr/bin/git ls-remote -h -t https://github.com/user/repo.git
# npm ERR!
# npm ERR! exited with error code: 128
# npm ERR! No git binary found in $PATH

# Step 1: Verify git is not installed
$ git --version
# -bash: git: command not found

# Step 2: Install git
# Ubuntu/Debian:
$ sudo apt-get update && sudo apt-get install -y git

# macOS:
$ brew install git
# Or: xcode-select --install (includes git)

# Alpine Linux (Docker):
$ apk add --no-cache git

# Step 3: For Docker, add to Dockerfile
# FROM node:18-alpine
# RUN apk add --no-cache git
# COPY package*.json ./
# RUN npm install

# Step 4: Verify the fix
$ git --version
# git version 2.43.0
$ npm install     # Should work now

# Alternative: Replace git dependencies with npm packages
# Change: "my-lib": "git+https://github.com/user/repo.git"
# To:     "my-lib": "npm:@user/repo@^1.0.0"  (if published)
Edge Cases & Unusual Scenarios

Git installed but SSH keys not available

npm can find git but the git+ssh:// dependency requires SSH keys that do not exist in the CI environment. Use git+https:// instead of git+ssh:// and provide a personal access token: git config --global url."https://token:YOUR_TOKEN@github.com/".insteadOf "git@github.com:"

Husky postinstall fails without git init

Husky (git hooks manager) runs a postinstall script that requires a .git directory. In CI or Docker where the project is copied without .git, Husky fails. Set the HUSKY=0 environment variable to skip hook installation in CI.

Windows PATH has Git Bash but not Git

Git for Windows includes Git Bash, which has git available inside the Bash shell but not in cmd.exe or PowerShell if the PATH option was not selected. Reinstall and choose "Git from the command line and also from 3rd-party software."

Optional follow-up

Some users ask whether saving fixes for recurring errors would be useful when the same issue appears again.

Was this explanation helpful?

Explanations are based on documented fixes, real-world reports, and common system behavior. GetErrorHelp is independent and not affiliated with software vendors, device manufacturers, or service providers.
Frequently Asked Questions

Why does npm need git?

Some packages install from git repositories.

How to avoid git deps?

Use published npm versions instead.

Which npm operations require git?

Installing packages from Git URLs (github:user/repo), resolving lockfile entries with Git references, running prepare scripts that call git (like Husky), and npm pack when creating a tarball that includes git metadata.

Can I avoid needing git entirely?

Yes, if all your dependencies are published to an npm registry (public or private) and none use git:// URLs. Check your package.json and package-lock.json for any git:// or github: references and replace them with published npm versions.

Why does the official Node.js Docker image not include git?

Docker images are kept minimal to reduce size and attack surface. The node:18-alpine image is about 120MB; adding git would increase it. The philosophy is to install only what you need explicitly.

Related Resources

Also Known As

Common Search Variations

Related Errors
Still Stuck?

Paste a different error message or upload a screenshot to get help instantly.

Solutions are based on commonly documented fixes and may not apply in all situations.