The current recommended way to install NodeJS can be seen on Node’s website.
Use the script they provide by running:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
Curl will download the script and “| bash” or pipe bash will run the script immediately, as if you typed it out manually.
Then run nvm install 22 (or whatever version you want to install).
To check, run:
node -v # Should print "v22.15.0".
nvm current # Should print "v22.15.0".
npm -v # Should print "10.9.2".