huangning
2026-07-18 c8c5a62d62b9ad05cfa0b5e026496b56a735a18f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
set -euo pipefail
 
if command -v node >/dev/null 2>&1; then
  node -v
  exit 0
fi
 
if command -v dnf >/dev/null 2>&1; then
  dnf install -y nodejs npm
elif command -v yum >/dev/null 2>&1; then
  yum install -y nodejs npm
elif command -v apt >/dev/null 2>&1; then
  apt update
  apt install -y nodejs npm
else
  echo "No supported package manager found. Install Node.js 18+ manually." >&2
  exit 1
fi
 
node -v
npm -v