diff --git a/backend/package-lock.json b/backend/package-lock.json index 9e25f833..df35fc8b 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -71,7 +71,7 @@ "supertest": "^6.3.3" }, "engines": { - "node": "^20.19.0 || >=22" + "node": ">=22.12.0" } }, "node_modules/@apidevtools/json-schema-ref-parser": { diff --git a/backend/package.json b/backend/package.json index 93cd11ba..c1349e73 100644 --- a/backend/package.json +++ b/backend/package.json @@ -4,7 +4,7 @@ "description": "Backend for PicPeak event photo sharing platform", "main": "server.js", "engines": { - "node": "^20.19.0 || >=22.12.0" + "node": ">=22.12.0" }, "scripts": { "start": "node server.js", diff --git a/scripts/picpeak-setup.sh b/scripts/picpeak-setup.sh index 2ef20be3..93bbfff4 100755 --- a/scripts/picpeak-setup.sh +++ b/scripts/picpeak-setup.sh @@ -14,8 +14,8 @@ IFS=$'\n\t' readonly SCRIPT_VERSION="2.1.0" readonly APP_NAME="PicPeak" readonly REPO_URL="https://github.com/PicPeak/picpeak.git" -readonly NODE_VERSION="20" -readonly NODE_MIN_VERSION="20.19.0" # backend engines: ^20.19.0 || >=22.12.0 (sharp 0.35, html-to-text 10; sanitize-html 2.17.7 needs require(esm), unflagged in 20.19 and 22.12) +readonly NODE_VERSION="22" +readonly NODE_MIN_VERSION="22.12.0" # backend engines: >=22.12.0 (sanitize-html 2.17.7) readonly MIN_RAM_DOCKER=2048 readonly MIN_RAM_NATIVE=1024 readonly MIN_DISK_GB=2 @@ -822,17 +822,11 @@ EOF # Native Installation ################################################################################ -# True when a Node.js version satisfies the backend's engines range -# (^20.19.0 || >=22.12.0). 21.x is out, and so is 22.0-22.11. +# True when a Node.js version satisfies the backend's engines range (>=22.12.0). node_version_supported() { - local ver="$1" major minor - major="${ver%%.*}" - minor="${ver#*.}"; minor="${minor%%.*}" - [[ "$major" =~ ^[0-9]+$ && "$minor" =~ ^[0-9]+$ ]] || return 1 - [[ "$(printf '%s\n' "$NODE_MIN_VERSION" "$ver" | sort -V | head -1)" == "$NODE_MIN_VERSION" ]] || return 1 - [[ "$major" == "21" ]] && return 1 - [[ "$major" == "22" && "$minor" -lt 12 ]] && return 1 - return 0 + local ver="$1" + [[ "$ver" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || return 1 + [[ "$(printf '%s\n' "$NODE_MIN_VERSION" "$ver" | sort -V | head -1)" == "$NODE_MIN_VERSION" ]] } install_nodejs() { @@ -843,9 +837,7 @@ install_nodejs() { local node_ver node_ver=$(command_exists node && node -v | cut -d'v' -f2 || echo "0") - # backend engines range is ^20.19.0 || >=22.12.0 (Node 21 is excluded by the glob/minimatch - # family; 22.0-22.11 lack unflagged require(esm), which sanitize-html 2.17.7's ESM-only - # htmlparser2 needs — the backend would not start) + # Match sanitize-html's declared Node minimum, including strict npm installs. if node_version_supported "$node_ver"; then log_success "Node.js $(node -v) is already installed" return @@ -864,10 +856,10 @@ install_nodejs() { ;; esac - # Package managers won't downgrade a newer Node (e.g. 21), so re-verify before continuing + # Re-verify in case the package manager did not replace an unsupported Node. node_ver=$(command_exists node && node -v | cut -d'v' -f2 || echo "0") if ! node_version_supported "$node_ver"; then - die "Node.js v$node_ver does not satisfy the backend requirement (^$NODE_MIN_VERSION || >=22.12.0); remove the current Node.js, install a supported version, then re-run this script" + die "Node.js v$node_ver does not satisfy the backend requirement (>=$NODE_MIN_VERSION); remove the current Node.js, install a supported version, then re-run this script" fi log_success "Node.js installed: $(node -v)" }