{"record":{"id":"abdbcc93e914d668","repo":"nodejs/node","slug":"add-this-npm-globalbin-to-your-path","errorCode":null,"errorMessage":"Add ${this.npm.globalBin} to your $PATH","messagePattern":"Add (.+?) to your \\$PATH","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"deps/npm/lib/commands/doctor.js","lineNumber":189,"sourceCode":"        maxLTS = version\n      }\n\n      if (semver.satisfies(version, currentRange) && semver.gt(version, maxCurrent)) {\n        maxCurrent = version\n      }\n    }\n    const recommended = semver.gt(maxCurrent, maxLTS) ? maxCurrent : maxLTS\n    if (semver.gte(process.version, recommended)) {\n      return `current: ${current}, recommended: ${recommended}`\n    } else {\n      throw `Use node ${recommended} (current: ${current})`\n    }\n  }\n\n  async getBinPath () {\n    log.info('doctor', 'getBinPath', 'Finding npm global bin in your PATH')\n    if (!process.env.PATH.includes(this.npm.globalBin)) {\n      throw new Error(`Add ${this.npm.globalBin} to your $PATH`)\n    }\n    return this.npm.globalBin\n  }\n\n  async checkCachePermission () {\n    return this.checkFilesPermission(this.npm.cache, true, R_OK)\n  }\n\n  async checkLocalModulesPermission () {\n    return this.checkFilesPermission(this.npm.localDir, true, R_OK | W_OK, true)\n  }\n\n  async checkGlobalModulesPermission () {\n    return this.checkFilesPermission(this.npm.globalDir, false, R_OK)\n  }\n\n  async checkLocalBinPermission () {\n    return this.checkFilesPermission(this.npm.localBin, false, R_OK | W_OK | X_OK, true)","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/npm/lib/commands/doctor.js#L171-L207","documentation":"doctor's getBinPath check tests whether npm's global bin directory is present in process.env.PATH. If the globalBin path is not a substring of PATH, it throws telling you to add it. Without it, globally installed binaries are not callable.","triggerScenarios":"Running `npm doctor` after installing node/npm via a method that places global bins outside PATH (custom prefix, manual install, some nvm/homebrew layouts).","commonSituations":"Custom npm prefix; switching node version managers; sudo-installed npm where globalBin is /usr/local/bin but user PATH omits it.","solutions":["Add the reported globalBin to PATH in your shell rc: export PATH=\"$(npm config get prefix)/bin:$PATH\"","Reinstall/relayout node via nvm so global bins land on PATH automatically","Verify with `echo $PATH` and `npm config get prefix`"],"exampleFix":"# before\nexport PATH=\"/usr/local/sbin:/usr/bin:/bin\"\n\n# after\nexport PATH=\"$(npm config get prefix)/bin:$PATH\"","handlingStrategy":"validation","validationCode":"function globalBinOnPath(globalBin) {\n  return process.env.PATH.split(path.delimiter).includes(globalBin)\n}","typeGuard":"function isGlobalBinOnPath(globalBin, p = process.env.PATH) {\n  return p.split(path.delimiter).some(dir => path.resolve(dir) === path.resolve(globalBin))\n}","tryCatchPattern":null,"preventionTips":["Add the npm global bin dir to PATH in your shell rc","Use a node version manager that maintains PATH automatically","Verify with `npm config get prefix` + `echo $PATH` after install changes"],"tags":["doctor","path","environment","global"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}