nodejs/node · error · Error
Add ${this.npm.globalBin} to your $PATH
Error message
Add ${this.npm.globalBin} to your $PATH What it means
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.
Source
Thrown at deps/npm/lib/commands/doctor.js:189
maxLTS = version
}
if (semver.satisfies(version, currentRange) && semver.gt(version, maxCurrent)) {
maxCurrent = version
}
}
const recommended = semver.gt(maxCurrent, maxLTS) ? maxCurrent : maxLTS
if (semver.gte(process.version, recommended)) {
return `current: ${current}, recommended: ${recommended}`
} else {
throw `Use node ${recommended} (current: ${current})`
}
}
async getBinPath () {
log.info('doctor', 'getBinPath', 'Finding npm global bin in your PATH')
if (!process.env.PATH.includes(this.npm.globalBin)) {
throw new Error(`Add ${this.npm.globalBin} to your $PATH`)
}
return this.npm.globalBin
}
async checkCachePermission () {
return this.checkFilesPermission(this.npm.cache, true, R_OK)
}
async checkLocalModulesPermission () {
return this.checkFilesPermission(this.npm.localDir, true, R_OK | W_OK, true)
}
async checkGlobalModulesPermission () {
return this.checkFilesPermission(this.npm.globalDir, false, R_OK)
}
async checkLocalBinPermission () {
return this.checkFilesPermission(this.npm.localBin, false, R_OK | W_OK | X_OK, true)View on GitHub (pinned to 1b2de5e052)
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`
Example fix
# before export PATH="/usr/local/sbin:/usr/bin:/bin" # after export PATH="$(npm config get prefix)/bin:$PATH"
Defensive patterns
Strategy: validation
Validate before calling
function globalBinOnPath(globalBin) {
return process.env.PATH.split(path.delimiter).includes(globalBin)
} Type guard
function isGlobalBinOnPath(globalBin, p = process.env.PATH) {
return p.split(path.delimiter).some(dir => path.resolve(dir) === path.resolve(globalBin))
} Prevention
- 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
When it happens
Trigger: Running `npm doctor` after installing node/npm via a method that places global bins outside PATH (custom prefix, manual install, some nvm/homebrew layouts).
Common situations: Custom npm prefix; switching node version managers; sudo-installed npm where globalBin is /usr/local/bin but user PATH omits it.
Related errors
- Install git and ensure it's in your PATH.
- ninja not found in PATH
- Some problems found. Check logs or disable silent mode for r
- Some problems found. See above for recommendations.
- Cannot use view command in global mode.
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/abdbcc93e914d668.
Report an issue: GitHub.