Skip to content

Instantly share code, notes, and snippets.

@thomasfr
Created August 30, 2012 21:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasfr/3541551 to your computer and use it in GitHub Desktop.
Save thomasfr/3541551 to your computer and use it in GitHub Desktop.
One liner to get latest stable version of node.js
curl --insecure -# -sSL http://nodejs.org/dist/ | sed -n -E "s/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/gp" | sort -u -k 1,1n -k 2,2n -k 3,3n -t . | tail -n1
@alshdavid
Copy link

For 2024:

NODE_VERSION=""; curl -sSL https://nodejs.org/download/release/ |  sed -E 's/<a.*>(v.*\..*\.[0-9]+\/)<\/a>.*/\1/g' |  grep "^v" | sed -E "s/v(.*)\//\1/g" | sort -u -k 1,1n -k 2,2n -k 3,3n -t . | grep "^${NODE_VERSION}" | tail -n1

And you can pick the version of Node.js by setting the NODE_VERSION variable

NODE_VERSION="20"; curl -sSL https://nodejs.org/download/release/ |  sed -E 's/<a.*>(v.*\..*\.[0-9]+\/)<\/a>.*/\1/g' |  grep "^v" | sed -E "s/v(.*)\//\1/g" | sort -u -k 1,1n -k 2,2n -k 3,3n -t . | grep "^${NODE_VERSION}" | tail -n1
NODE_VERSION="20.10"; curl -sSL https://nodejs.org/download/release/ |  sed -E 's/<a.*>(v.*\..*\.[0-9]+\/)<\/a>.*/\1/g' |  grep "^v" | sed -E "s/v(.*)\//\1/g" | sort -u -k 1,1n -k 2,2n -k 3,3n -t . | grep "^${NODE_VERSION}" | tail -n1

(I'm not good at sed/regex so it does multiple passes, feel free to simplify this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment