We know that when we install an application we’re not just installing a single file. Instead we’re copying a whole set of files that have dependencies to each other in order for the application to install and function correctly.
When we’re using the command line we can use package managers that take care of ensuring that all the necessary files are copied over to the correct locations.
In addition a package manager will lets us access a registry of applications that we can install from. You may already have come across the Node.js Packet Manager that uses the prefix npm.
Another commonly used packet manager for OS X is Brew which we can use to install Node.js.
As the Brew website shows us installing Brew is as easy as opening up Terminal and using copying and pasting the following:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It may take a while but it will install. As you can see this requires Ruby which comes pre-installed with OS X.
As soon as this is installed we can use the registry of over 3,000 command line applications like:
- ffmpeg – for video/audio encoding
- wget – for retrieving files via the command line
- git – for version control
All with a simple:
brew install application_name
NPM for Node.js
So if we want to install Node.js we just use:
brew install node
Now that Node.js is installed we can easily install applications that depend on it. Those applications can be found at the NPM (Node Packet Manager) Registry and include packages such as:
- Grunt – task runner which automates tasks like minification and testing
- Less – the other CSS pre-processor
In addition we can also install Bower, a package manager for web projects.
Often we are starting a web job with perhaps one or more frameworks and / or libraries. Just as the other package managers collect all the required files and dependencies for an application to install and run, Bower gathers the latest or a particular version of a framework, library or other assets we may need to start a web project.
To install Bower (we also need to have Git installed too):
sudo npm install -g bower
It might also take a while but now we have access to the Bower package registry which for the most part just copies the files we need from GitHub. So, for a project that requires Bootstrap we first select our directory using the cd command and then:
bower install bootstrap
This will pull the the latest version of Bootstrap including all dependencies into our folder.
We can also create our own Bower packages with a JSON manifest.
Not a big fan of the command line? Check out the Bower Browser.