Previously, if we had to install a new node version, we activated it in
the same subshell as the installation. This had the effect that `NVM_BIN`
was set to the new version only in the subshell, but otherwise it still
had the wrong value. This caused build failures. Subsequent builds would
succeed because the node version was now available.
This change fixes things by using an explicit `if` instead of the
construct with parens which opened another subshell.
Fixes: #14056
Test-bot: skip
`nvm install` will fail if trying to build while offline. This
change tries to use the required node version first and if that
fails installs and then uses it.