#给你个脚本。
#升级到最新
VERSION=$(curl
http://nodejs.org/download/ | grep 'Current version:' | grep -o "v[0-9]\+\.[0-9]\+\.[0-9]\+")
#check if linux is 64 or 32 bit
if [ "$SYS64" == 1 ]; then
FILENAME="node-${VERSION}-linux-x64.tar.gz"
else
FILENAME="node-${VERSION}-linux-x86.tar.gz"
fi
wget "
http://nodejs.org/dist/${VERSION}/${FILENAME}"
tar -zxf "${FILENAME}" -C /usr/local/ --strip-components=1
rm -f "${FILENAME}"
if [ $(node -v) == $VERSION ]; then
echo "Upgrade successful $VERSION"
fi
############################################################
#升级到特定版本,例如0.8.20
VERSION="v0.8.20"
if [ $(uname -m | grep '64' | wc -l) == 1 ]; then
FILENAME="node-${VERSION}-linux-x64.tar.gz"
else
FILENAME="node-${VERSION}-linux-x86.tar.gz"
fi
wget "
http://nodejs.org/dist/${VERSION}/${FILENAME}"
tar -zxf "${FILENAME}" -C /usr/local/ --strip-components=1
rm -f "${FILENAME}"
if [ $(node -v) == $VERSION ]; then
echo "Upgrade successful $VERSION"
fi