Check and remove Node.js if version is not 22

Remove existing Node.js installation if version is not 22.
This commit is contained in:
CanbiZ 2025-10-22 17:18:35 +02:00 committed by GitHub
parent c7fffd85d3
commit c92f9d5518
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,6 +27,19 @@ function update_script() {
msg_error "No ${APP} Installation Found!"
exit
fi
if command -v node &> /dev/null; then
CURRENT_NODE_VERSION=$(node --version | cut -d'v' -f2 | cut -d'.' -f1)
if [[ "$CURRENT_NODE_VERSION" != "22" ]]; then
systemctl stop openresty
apt-get purge -y nodejs npm
apt-get autoremove -y
rm -rf /usr/local/bin/node /usr/local/bin/npm
rm -rf /usr/local/lib/node_modules
rm -rf ~/.npm
rm -rf /root/.npm
fi
fi
NODE_VERSION="22" NODE_MODULE="yarn" setup_nodejs
export NODE_OPTIONS="--openssl-legacy-provider"