@@ -305,6 +305,23 @@ if [ $CURL_RC -eq 0 ]; then
305305 np2=$( npm -v 2> /dev/null)
306306 echo " Node.js $nv2 and Npm $np2 already installed" | $SUDO tee -a /var/log/nodered-install.log >> /dev/null
307307 echo -ne " Node.js $nv2 and Npm $np2 already installed.\n\n"
308+
309+ # Decide whether the currently installed Node.js needs upgrading
310+ # because it is older than the minimum supported version of 22.9.0
311+ NV_MAJOR=$( echo " $nv2 " | sed ' s/^v//' | cut -d ' .' -f1)
312+ NV_MINOR=$( echo " $nv2 " | sed ' s/^v//' | cut -d ' .' -f2)
313+ NEEDS_UPGRADE=" n"
314+ if [[ " $NV_MAJOR " -lt 22 ]] || { [[ " $NV_MAJOR " -eq 22 ]] && [[ " ${NV_MINOR:- 0} " -lt 9 ]]; }; then
315+ NEEDS_UPGRADE=" y"
316+ fi
317+ if [[ " $NEEDS_UPGRADE " == " y" && " $FORCE_NODE " != " y" ]]; then
318+ echo " Installed nodejs $nv2 is below the minimum of 22.9.0 - will remove and install new version" | $SUDO tee -a /var/log/nodered-install.log >> /dev/null
319+ echo " "
320+ echo " Node-RED requires Nodejs 22.9.0 or later - you have $nv2 "
321+ echo " Will attempt to remove the existing Node.js and install $NODE_VERSION ."
322+ echo " "
323+ FORCE_NODE=" y"
324+ fi
308325 else
309326 echo " Node.js and Npm not found - will try to install Node.js $NODE_VERSION " | $SUDO tee -a /var/log/nodered-install.log >> /dev/null
310327 echo -ne " Node.js and Npm not found - will try to install Node.js $NODE_VERSION \n\n"
@@ -428,6 +445,7 @@ if [ $CURL_RC -eq 0 ]; then
428445
429446 # use the official script to install for other debian platforms
430447 $SUDO rm -rf /etc/apt/sources.list.d/nodesource.list 2>&1 | $SUDO tee -a /var/log/nodered-install.log >> /dev/null
448+ $SUDO rm -rf /etc/apt/sources.list.d/nodesource.sources 2>&1 | $SUDO tee -a /var/log/nodered-install.log >> /dev/null
431449 $SUDO apt install -y ca-certificates curl gnupg 2>&1 | $SUDO tee -a /var/log/nodered-install.log >> /dev/null
432450 $SUDO mkdir -p /etc/apt/keyrings 2>&1 | $SUDO tee -a /var/log/nodered-install.log >> /dev/null
433451 curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | $SUDOE gpg --batch --yes --dearmor -o /etc/apt/keyrings/nodesource.gpg 2>&1 | $SUDO tee -a /var/log/nodered-install.log >> /dev/null
0 commit comments