Node.js is actually an essential tool for every developer. Basically are a javascript interpreter for a command line. This is very interesting because allows executing javascript in any environment; you can make server-side applications, command-line tools, webs, etc. An actually have a lot of followers, apps, frameworks to work with it. This ecosystem is incredible and make it easier life when you work with it.
But Node isn’t alone. Come with another powerful tool called npm. Npm is a package manager that allows installing of third party libraries in javascript. For development, this is amazing because you could have an entire development environment in minutes.
Let’s do install Node.
Install Node
you have two ways to install in Mac OS X.
Use Installer
The easiest way to install a node is with the package manager.
- Go to https://nodejs.org/en/download/
- Download Mac installer version
- Execute and follow step by step
Use Homebrew
Homebrew is defined as a package manager that OS X should have. First, we need to install homebrew. Open a terminal window and write:
1 | $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
After some text, you can test it works:
1 2 3 | $ brew -v Homebrew 1.2.3 Homebrew/homebrew-core (git revision 501b; last commit 2017-06-27) |
Now we can install Node:
1 | $ brew install node |
And after some more text, you will be Node.JS installed.
Test It
If you open a terminal and write:
1 | $ node -v && npm -v |
You will have the version output:
1 2 | v8.1.4 5.3.0 |
Why use Homebrew instead Installer
Why is better to use homebrew instead of the installer? Easy, you need administrative privileges to install, this means use Sudo to install with package installer and are a big problem for working with it. You will need to use Sudo in front of the node and this one doesn’t like execution with root privileges. To avoid this problem use Homebrew to install it.