nodejs/node · error · Error
Install git and ensure it's in your PATH.
Error message
Install git and ensure it's in your PATH.
What it means
doctor's getGitPath check uses which('git') to locate git; on failure (git not installed or not on PATH) it catches and rethrows this friendly error. Several npm flows (git dependencies) need git, so doctor reports its absence as a failed check.
Source
Thrown at deps/npm/lib/commands/doctor.js:279
}
}
} finally {
if (!ok) {
throw (
`Check the permissions of files in ${root}` +
(shouldOwn ? ' (should be owned by current user)' : '')
)
} else {
return ''
}
}
}
async getGitPath () {
log.info('doctor', 'Finding git in your PATH')
return await which('git').catch(er => {
log.warn('doctor', 'getGitPath', er)
throw new Error("Install git and ensure it's in your PATH.")
})
}
async verifyCachedFiles () {
log.info('doctor', 'verifyCachedFiles', 'Verifying the npm cache')
const stats = await cacache.verify(this.npm.flatOptions.cache)
const { badContentCount, reclaimedCount, missingContent, reclaimedSize } = stats
if (badContentCount || reclaimedCount || missingContent) {
if (badContentCount) {
log.warn('doctor', 'verifyCachedFiles', `Corrupted content removed: ${badContentCount}`)
}
if (reclaimedCount) {
log.warn(
'doctor',
'verifyCachedFiles',
`Content garbage-collected: ${reclaimedCount} (${reclaimedSize} bytes)`View on GitHub (pinned to 1b2de5e052)
Solutions
- Install git (apt-get install git, brew install git, etc.)
- Ensure the git executable directory is on PATH
- For containers, add git to the image (RUN apt-get update && apt-get install -y git)
Defensive patterns
Strategy: validation
Validate before calling
const which = require('which')
function gitAvailable() {
try { which.sync('git'); return true } catch { return false }
} Type guard
function hasGitInPath() {
try { require('which').sync('git'); return true } catch { return false }
} Prevention
- Install git and put it on PATH
- Add git to minimal container images
- For git-dependencies, ensure git is present before install, not just before doctor
When it happens
Trigger: Running `npm doctor` on a system without git, or where git is installed but not on PATH (minimal Docker images, fresh Windows, sandboxed CI).
Common situations: Slim container images that omit git; Windows without Git for Windows on PATH; sandboxed build environments.
Related errors
- Add ${this.npm.globalBin} to your $PATH
- Some problems found. Check logs or disable silent mode for r
- Some problems found. See above for recommendations.
- No dependencies found matching ${args.join(', ')}
- found no installed dependencies to audit
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/5393a2f2e58b1e5c.
Report an issue: GitHub.