From d84ac67ffcc459bb560b8e723c24a6a2e1e051cb Mon Sep 17 00:00:00 2001 From: Justin Rost Date: Fri, 28 Feb 2025 08:58:58 +0100 Subject: [PATCH] node via n --- Init-Server.sh | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/Init-Server.sh b/Init-Server.sh index adae5ed..93ff2ab 100644 --- a/Init-Server.sh +++ b/Init-Server.sh @@ -106,22 +106,26 @@ install_docker() { # Function to install Node.js install_nodejs() { if get_user_confirmation "Node.js installieren?"; then - if command_exists node; then - log_info "Node.js ist bereits installiert." - else - log_info "Node.js wird installiert..." - apt install -y curl - # Using the latest LTS version (20.x as of now) - curl -fsSL https://deb.nodesource.com/setup_20.x | bash - - apt install -y nodejs - - # Install latest npm version - npm install -g npm@latest - - log_success "Node.js wurde erfolgreich installiert." - log_info "Installed Node.js version: $(node --version)" - log_info "Installed npm version: $(npm --version)" - fi + log_info "Node.js wird installiert/aktualisiert..." + + # Install npm first + apt install -y npm + + # Update npm to latest version + npm install -g npm@latest + + # Install n module for Node.js version management + npm install -g n + + # Install latest stable Node.js version using n + n stable + + # Reload shell environment to use new Node.js version + export PATH="$PATH" + + log_success "Node.js wurde erfolgreich installiert/aktualisiert." + log_info "Installed Node.js version: $(node --version)" + log_info "Installed npm version: $(npm --version)" else log_skip "Node.js-Installation übersprungen." fi @@ -175,9 +179,8 @@ display_system_overview() { if command_exists ufw; then echo "✓ UFW ($(ufw status | grep Status | cut -d' ' -f2))" fi - echo -e "\n${BLUE}[Open Ports]${NC}" - netstat -tuln | grep LISTEN | awk '{print $4}' | sed 's/.*://' + netstat -tuln | grep LISTEN | awk '{print $4}' | sed 's/.*://' | tr '\n' ', ' | sed 's/,$/\n/' echo -e "\n${GREEN}Setup completed! System is ready to use.${NC}\n" }