From b7a9d517e74beabc4aa2b74deb6b65a59c7c20e5 Mon Sep 17 00:00:00 2001
From: tteckster <tteckster@gmail.com>
Date: Mon, 1 Jan 2024 15:02:21 -0500
Subject: [PATCH] Update node-red.sh

(node 18.x has stopped utilizing npm by default)

- check if the installed version of Node.js is 18.x and, if so, ensures that npm is also installed.
- fixes https://github.com/tteck/Proxmox/issues/2283
---
 ct/node-red.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ct/node-red.sh b/ct/node-red.sh
index 764d558b..962ab584 100644
--- a/ct/node-red.sh
+++ b/ct/node-red.sh
@@ -58,6 +58,13 @@ UPD=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --radio
   3>&1 1>&2 2>&3)
 header_info
 if [ "$UPD" == "1" ]; then
+  if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then
+    if ! command -v npm >/dev/null 2>&1; then
+      msg_info "Installing NPM"
+      apt-get install -y npm >/dev/null 2>&1
+      msg_ok "Installed NPM"
+    fi
+  fi
 msg_info "Stopping ${APP}"
 systemctl stop nodered
 msg_ok "Stopped ${APP}"