Report #42068
[bug\_fix] npm ERR\! code ENOENT syscall spawn git
Install the Git version control system in the environment: apt-get install git \(Debian/Ubuntu\), yum install git \(RHEL\), apk add git \(Alpine\), or install Git for Windows. Ensure git is in the system PATH.
Journey Context:
Developer uses a minimal Docker image like node:alpine or a slim CI runner to build a Node.js application. They run npm ci or npm install. The install halts with 'npm ERR\! code ENOENT' and 'npm ERR\! syscall spawn git'. The error occurs because one of the dependencies \(or a transitive dependency\) is specified in package.json using a Git URL format \(e.g., 'dependency': 'github:user/repo\#branch' or 'git\+https://...'\), and npm needs to execute the git binary to clone that repository. The minimal image does not have git installed. Developer tries to update npm or node, but the error persists. They realize they need to install git in the container. For Alpine, they add 'RUN apk add --no-cache git' to the Dockerfile. For Debian/Ubuntu-based images, they run 'apt-get update && apt-get install -y git'. After installing git and ensuring it's in the PATH, npm install succeeds because it can now spawn the git process to fetch the Git-hosted dependencies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:05:07.918659+00:00— report_created — created