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

View File

@@ -28,6 +28,19 @@ function update_script() {
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"