fix: warn before npm prefix redirection (#73890) (thanks @Sayeem3051)

This commit is contained in:
Peter Steinberger
2026-04-30 04:39:33 +01:00
parent bbf932fd7d
commit 5f13af6b68
3 changed files with 57 additions and 0 deletions

View File

@@ -1633,9 +1633,12 @@ fix_npm_permissions() {
return 0
fi
ui_warn "npm global prefix is not writable: ${npm_prefix}"
ui_warn "The installer will switch npm's user prefix to ${HOME}/.npm-global; npm normally writes that setting to ~/.npmrc."
ui_info "Configuring npm for user-local installs"
mkdir -p "$HOME/.npm-global"
npm config set prefix "$HOME/.npm-global"
ui_warn "Avoid sudo npm i -g for future OpenClaw updates; use npm i -g openclaw@latest so npm keeps using this user prefix instead of a different global prefix."
# shellcheck disable=SC2016
local path_line='export PATH="$HOME/.npm-global/bin:$PATH"'