Install Node.Js On Mac Os X
Install Node.js on Mac OS X
Akbar S. Ahmed | Jan 20, 2015

Step-by-step instructions

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.

vi ~/.bash_profile

Append the following to the bottom of your .bash_profile file:

# include locally installed Node.js in PATH
if [ -d "$HOME/opt" ]; then
    PATH="$PATH:$HOME/opt/node/bin"
fi

Source your .bash_profile file and test Node.

source ~/.bash_profile

Ensure that the node command is in your PATH.

which node

Check the node version.

node --version

You should see: v0.10.34.

Check the npm version.

npm --version

You should see: 1.4.28.

Congrats, you have just installed a local copy of Node.js for development.




Subscribe to our newsletter

Contact Information

ABOUT EXPONENTIAL.IO

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.

LOCATION

All courses are made with love in
Palo Alto, CA.

Subscribe to our newsletter