Make the wget/curl lookup more robust and portable

Get rid of unreliable globbing for the downloaded node.js distribution by using deterministic output file name.

Do not rely on "which" reporting an error because that's not portable - on some plaftorms it doesn't report an error if it finds nothing. Replace it with more portable and readable code.