Skip to content

Instantly share code, notes, and snippets.

@tbranyen
Created May 1, 2012 16:27
Show Gist options
  • Save tbranyen/2569416 to your computer and use it in GitHub Desktop.
Save tbranyen/2569416 to your computer and use it in GitHub Desktop.
Easily install new or old versions of Node.js on an OS X machine.
#!/bin/bash
#
# Copyright 2012, Tim Branyen @tbranyen <[email protected]>
# Dual licensed under the MIT and GPL licenses.
#
# Easily install new or old versions of Node.js on an OS X machine.
#
# Install: curl -o /usr/local/bin/install_node https://gist.github.com/raw/2569416/install_node.sh
# chmod +x /usr/local/bin/install_node
#
# Usage: install_node 0.6.16
#
# Specify the version as the single argument, if you want to customize the
# cache directory, you can modify this file or prefix with:
#
# DIR=~/.cache install_node 0.6.16
#
# Configure the installer cache directory
DIR=~/.node
# Configure the target harddisk to install to
TARGET=/Volumes/Macintosh\ HD
# Pass version in as an argument
VER=$*
# If install file doesn't already exist, fetch it first
if [ ! -f ~/.node/$VER.pkg ]; then
# Fetch the package into a hidden directory
curl --create-dirs -o $DIR/$VER.pkg \
http://nodejs.org/dist/v$VER/node-v$VER.pkg
fi
# Invoke the installer
sudo installer -pkg $DIR/$VER.pkg -target $TARGET
@danro
Copy link

danro commented Jun 25, 2012

L34 should be -target $TARGET

This script is rad btw.

@tbranyen
Copy link
Author

Updated thanks @danro!

@max-mapper
Copy link

to install: ./install_node.sh 0.8.0

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