npm 없으면 설치
This commit is contained in:
1 parent
51cfb95b81
commit
eb52bbd9d3
2 files changed
+76
-1
No files matched your search
@@ -58,6 +58,51 @@ for cmd in curl; do
|
||||
command -v "$cmd" &>/dev/null || error "'$cmd' is required."
|
||||
done
|
||||
|
||||
# Check for Node.js (npm) — install if missing
|
||||
if ! command -v npm &>/dev/null; then
|
||||
info "npm is not installed. Installing Node.js..."
|
||||
case "$OS" in
|
||||
Darwin)
|
||||
if command -v brew &>/dev/null; then
|
||||
brew install node
|
||||
success "Node.js installed via Homebrew"
|
||||
else
|
||||
error "Homebrew (brew) is required to install Node.js on macOS. Install it from https://brew.sh/"
|
||||
fi
|
||||
;;
|
||||
Linux)
|
||||
if command -v apt-get &>/dev/null; then
|
||||
sudo apt-get update -y && sudo apt-get install -y nodejs npm
|
||||
success "Node.js installed via apt-get"
|
||||
elif command -v dnf &>/dev/null; then
|
||||
sudo dnf install -y nodejs
|
||||
success "Node.js installed via dnf"
|
||||
elif command -v yum &>/dev/null; then
|
||||
sudo yum install -y nodejs
|
||||
success "Node.js installed via yum"
|
||||
elif command -v zypper &>/dev/null; then
|
||||
sudo zypper -n install nodejs npm
|
||||
success "Node.js installed via zypper"
|
||||
elif command -v pacman &>/dev/null; then
|
||||
sudo pacman -S --noconfirm nodejs npm
|
||||
success "Node.js installed via pacman"
|
||||
else
|
||||
error "No supported package manager found. Install Node.js 18+ manually: https://nodejs.org/"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
error "Cannot auto-install Node.js on this OS. Install Node.js 18+ manually: https://nodejs.org/"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Verify npm is now available
|
||||
if ! command -v npm &>/dev/null; then
|
||||
error "Node.js installation completed but npm not found. Install Node.js 18+ manually: https://nodejs.org/"
|
||||
fi
|
||||
fi
|
||||
|
||||
info "npm is available: $(command -v npm)"
|
||||
|
||||
# ────────────────────────────────────────────
|
||||
# Detect OS / Architecture
|
||||
# ────────────────────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user