@@ -851,6 +851,59 @@ rollback() {
851851 exit 1
852852}
853853
854+ # Check installed Node.js version and upgrade if needed
855+ check_node_version () {
856+ if ! command -v node & > /dev/null; then
857+ log_error " Node.js is not installed"
858+ exit 1
859+ fi
860+
861+ local current major_version
862+
863+ current=$( node -v 2> /dev/null | tr -d ' v' )
864+ major_version=${current%% .* }
865+
866+ log " Detected Node.js version: $current "
867+
868+ if (( major_version < 24 )) ; then
869+ log_warning " Node.js < 24 detected → upgrading to Node.js 24 LTS..."
870+ upgrade_node_to_24
871+ elif (( major_version > 24 )) ; then
872+ log_warning " Node.js > 24 detected → script tested only up to Node 24"
873+ log " Continuing anyway…"
874+ else
875+ log_success " Node.js 24 already installed"
876+ fi
877+ }
878+
879+ # Upgrade Node.js to version 24
880+ upgrade_node_to_24 () {
881+ log " Preparing Node.js 24 upgrade…"
882+
883+ # Remove old nodesource repo if it exists
884+ if [ -f /etc/apt/sources.list.d/nodesource.list ]; then
885+ rm -f /etc/apt/sources.list.d/nodesource.list
886+ fi
887+
888+ # Install NodeSource repo for Node.js 24
889+ curl -fsSL https://deb.nodesource.com/setup_24.x -o /tmp/node24_setup.sh
890+ if ! bash /tmp/node24_setup.sh > /tmp/node24_setup.log 2>&1 ; then
891+ log_error " Failed to configure Node.js 24 repository"
892+ tail -20 /tmp/node24_setup.log | while read -r line; do log_error " $line " ; done
893+ exit 1
894+ fi
895+
896+ log " Installing Node.js 24…"
897+ if ! apt-get install -y nodejs >> " $LOG_FILE " 2>&1 ; then
898+ log_error " Failed to install Node.js 24"
899+ exit 1
900+ fi
901+
902+ local new_ver
903+ new_ver=$( node -v 2> /dev/null || true)
904+ log_success " Node.js successfully upgraded to $new_ver "
905+ }
906+
854907# Main update process
855908main () {
856909 # Check if this is the relocated/detached version first
@@ -913,6 +966,12 @@ main() {
913966
914967 # Stop the application before updating
915968 stop_application
969+
970+ # Check Node.js version
971+ check_node_version
972+
973+ # Update Node.js to 24
974+ upgrade_node_to_24
916975
917976 # Download and extract release
918977 local source_dir
0 commit comments