Installing Node.js on Mac OS X without using Homebrew or the installer is easy. The instructions in this post are for setting up a development machine and do not include all of the steps required for a production installation.
Of the three installation methods, the installer is probably the easiest, but it requires sudo to install Node.js into system directories. Homebrew is also easy but requires Homebrew (which I do not currently use). Lastly, installing from the pre-built binary is also easy, which is what is covered here.
We are going to install Node.js into our home directory so that we do not need to use sudo during development. Also, we will use a symlink so that we can quickly switch between versions of Node.js.
An alternative for managing multiple versions of node is nvm.
Create a directory structure to store locally installed packages.
mkdir -p ~/opt/packages && cd $_
Change the version numbers below as new versions of Node are released.
Download the node.js package.
curl -O http://nodejs.org/dist/v0.10.34/node-v0.10.34-darwin-x64.tar.gz
Unzip the package.
gzip -dc node-v0.10.34-darwin-x64.tar.gz | tar xf -
Create a symlink to the currently installed version. We can change the symlink in the future to easily upgrade our node version.
ln -s ~/opt/packages/node-v0.10.34-darwin-x64/ ~/opt/node
Add node to your PATH.
Append the following to the bottom of your
# include locally installed Node.js in PATH if [ -d "$HOME/opt" ]; then PATH="$PATH:$HOME/opt/node/bin" fi
.bash_profile file and test Node.
Ensure that the node command is in your PATH.
Check the node version.
You should see: v0.10.34.
Check the npm version.
You should see: 1.4.28.
Congrats, you have just installed a local copy of Node.js for development.
We specialize in helping professional developers, like you, expand your skill set. Our courses are focused on enabling you to learn everything necessary to use a new technology in a live, production application.
All courses are made with love in
Palo Alto, CA.
Subscribe to our newsletter