Installing Node.js, npm, and redis on Mac OS X

Main Thread 2 min read

Update: Node.js now has a package installer for Mac OS X which includes node and npm. Unless you need to install node or npm by hand, I suggest downloading the package installer.

I've been wanting to mess with I/O Docs for some time now. I/O Docs requires Node.js, npm, and redis. I hear the buzz around these technologies, but I have yet to use them. Although I found several posts and a package for installing Node.js and npm on Mac OS X, each had issues. Mac OS X runs atop BSD Unix. So, while potentially intimidating, you can install all these yourself by running commands within Terminal.

Installing Node.js

After much Googling I discovered an overwhelming set of Node.js installation instructions. In a nutshell (no pun), this installs Node.js under a newly created local folder in the current user folder and adds that folder to your PATH so you can run Node.js simply by typing node.

1echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bash_profile
2source ~/.bash_profile
3mkdir ~/local
4mkdir ~/node-js
5cd ~/node-js
6curl http://nodejs.org/dist/node-v0.4.7.tar.gz | tar xz --strip-components=1
7./configure --prefix=~/local
8make install

A few notes.

First, this installs Node.js version 0.4.7. From what I read, this is currently the most compatible version. If you require a different version, I'll assume you know more about installing Node.js than me.

Second, bash on Mac OS X uses .bash_profile not .bashrc. I've modified the original script to reflect these changes.

Installing npm

Once you have installed Node.js, you can install npm with just one command.

1curl http://npmjs.org/install.sh | sh

I should pass along the warning that this runs commands streamed from the internet. If you're paranoid about that kind of stuff, you should download and verify install.sh first.

Installing Redis

Redis was a straightforward install. For the most part I followed the redis quickstart guide. I modified the script below slightly to use curl as Mac OS X does not include wget.

1curl -O http://download.redis.io/redis-stable.tar.gz
2tar -xvzf redis-stable.tar.gz
3rm redis-stable.tar.gz
4cd redis-stable
5make
6sudo make install

Note: rm redis-stable.tar.gz is simple cleanup. sudo make install is optional as it adds the Redis commands to /usr/local/bin/.

In closing

In time, you may need to update the versions for Node.js and Redis. Both offer a latest download. Feel free to substitute these into your script. The commands above should still work. Nonetheless, I tried to provide links to the original documentation when available.

This post came from getting started with I/O Docs. As I/O Docs required Node.js and redis.

Find this interesting? Let's continue the conversation on Twitter.