fix: robust node.js version parsing in installers
Improved Node.js version check logic to handle prefixed version strings and avoid brittle cut commands. Verified with multiple version formats including v24.11.1.
This commit is contained in:
@@ -69,9 +69,11 @@ check_prerequisites() {
|
||||
check_command "curl"
|
||||
|
||||
# Check Node.js version (need 14+)
|
||||
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
|
||||
if [ "$NODE_VERSION" -lt 14 ]; then
|
||||
log_error "Node.js version 14 or higher required. Current: $(node -v)"
|
||||
local node_full_version=$(node -v 2>&1)
|
||||
local node_major_version=$(echo "$node_full_version" | grep -oE '[0-9]+' | head -n1)
|
||||
|
||||
if [ -z "$node_major_version" ] || [ "$node_major_version" -lt 14 ]; then
|
||||
log_error "Node.js version 14 or higher required. Current: $node_full_version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user