Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
download-node-nightly.sh - simple script to fetch Node.js nightlies on OS X and Linux (x86, x64 & ARM)
#!/bin/bash
# Usage:
# bash download-node-nightly.sh
hasxz=$(which xzcat)
os=$(uname | tr '[A-Z]' '[a-z]')
arch=$(uname -m)
pwd=$(PWD)
[[ "$arch" == "x86_64" ]] && arch=x64
[[ "$arch" == "x686" ]] && arch=x32
type=nightly
echo -e "Getting latest list of nightlies…\n"
latest=$(curl -sL https://nodejs.org/download/${type}/index.tab | head -2 | tail -1 | awk '{ print $1 }')
while true; do
echo -n "Download Node.js ${latest} (${os}/${arch})? [y/n] "
yorn=""
read yorn
if [ "X${yorn}" == "Xn" ]; then
break
fi
if [ "X${yorn}" == "Xy" ]; then
echo -e "Downloading…\n\n"
url="https://nodejs.org/download/${type}/$latest/node-${latest}-${os}-x64.tar"
if [ "X${hasxz}" == "X" ]; then
url="${url}.gz"
pipecmd="| tar -zx -C ./"
else
url="${url}.xz"
pipecmd="| xzcat | tar -x -C ./"
fi
bash -c "curl -L --progress-bar '${auth}' '${url}' ${pipecmd}"
echo ""
echo "Downloaded and extracted to ${pwd}/node-${latest}-${os}-x64/"
echo ""
echo "The new node binary is located here:"
echo " ./node-${latest}-${os}-x64/bin/node"
break
fi
done
@paulirish

This comment has been minimized.

Copy link
Owner Author

commented Jun 24, 2016

This gist is a small fork of rvagg's one here: https://gist.github.com/rvagg/742f811be491a49ba0b9

Changes are mostly that this defaults to nightly and doesn't attempt to install to /usr/local.

@hemanth

This comment has been minimized.

Copy link

commented Jun 24, 2016

@paulirish Shouldn't ${os}-x64 be ${os}-${arch} ?
'${auth}' is missing.

I have reported the same in Rvagg's script, thanks!

@hemanth

This comment has been minimized.

Copy link

commented Jun 25, 2016

BTW node-nightly at your finger tips! https://git.io/node-nightly ;)

@paulirish

This comment has been minimized.

Copy link
Owner Author

commented Jun 27, 2016

FYI all: hemanth has a nice script to simplify running the above: https://github.com/hemanth/node-nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.