Skip to content

Add npm check to doctor #764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions bin/n
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,20 @@ function show_diagnostics() {
fi
fi

# Check npm too. Simpler check than for PATH and node, more like the runtime logging for active/installed node.
if [[ -z "${N_PRESERVE_NPM}" ]]; then
printf "\nChecking npm install destination...\n"
local installed_npm="${N_PREFIX}/bin/npm"
local active_npm="$(command -v npm)"
if [[ -e "${active_npm}" && -e "${installed_npm}" && "${active_npm}" != "${installed_npm}" ]]; then
echo_red "There is an active version of npm shadowing the version installed by n. Check order of entries in PATH."
log "installed" "${installed_npm}"
log "active" "${active_npm}"
else
printf "good\n"
fi
fi

printf "\nChecking permissions for cache folder...\n"
# Most likely problem is ownership rather than than permissions as such.
local cache_root="${N_PREFIX}/n"
Expand Down