{"record":{"id":"5393a2f2e58b1e5c","repo":"nodejs/node","slug":"install-git-and-ensure-it-s-in-your-path","errorCode":null,"errorMessage":"Install git and ensure it's in your PATH.","messagePattern":"Install git and ensure it's in your PATH\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/commands/doctor.js","lineNumber":279,"sourceCode":"        }\n      }\n    } finally {\n      if (!ok) {\n        throw (\n          `Check the permissions of files in ${root}` +\n          (shouldOwn ? ' (should be owned by current user)' : '')\n        )\n      } else {\n        return ''\n      }\n    }\n  }\n\n  async getGitPath () {\n    log.info('doctor', 'Finding git in your PATH')\n    return await which('git').catch(er => {\n      log.warn('doctor', 'getGitPath', er)\n      throw new Error(\"Install git and ensure it's in your PATH.\")\n    })\n  }\n\n  async verifyCachedFiles () {\n    log.info('doctor', 'verifyCachedFiles', 'Verifying the npm cache')\n\n    const stats = await cacache.verify(this.npm.flatOptions.cache)\n    const { badContentCount, reclaimedCount, missingContent, reclaimedSize } = stats\n    if (badContentCount || reclaimedCount || missingContent) {\n      if (badContentCount) {\n        log.warn('doctor', 'verifyCachedFiles', `Corrupted content removed: ${badContentCount}`)\n      }\n\n      if (reclaimedCount) {\n        log.warn(\n          'doctor',\n          'verifyCachedFiles',\n          `Content garbage-collected: ${reclaimedCount} (${reclaimedSize} bytes)`","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/doctor.js#L261-L297","documentation":"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.","triggerScenarios":"Running `npm doctor` on a system without git, or where git is installed but not on PATH (minimal Docker images, fresh Windows, sandboxed CI).","commonSituations":"Slim container images that omit git; Windows without Git for Windows on PATH; sandboxed build environments.","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)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const which = require('which')\nfunction gitAvailable() {\n  try { which.sync('git'); return true } catch { return false }\n}","typeGuard":"function hasGitInPath() {\n  try { require('which').sync('git'); return true } catch { return false }\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["doctor","git","environment","dependencies"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}