Installing node.js on OSX 10.11 El

by keen

node.js allows you to run javascript in the Terminal as appose to a regular browser which makes for a modern workflow in web development, with node.js installed an a package manager called npm (Node Package Manager) is also installed which can manage other packages that utilize node.js, one of the main ones being grunt.js for web development workflow.

To install node.js on OSX 10.11 El Capitan (or OSX 10.10 and OSX 10.9)  you can download a pre-compiled binary package which makes a nice and easy installation. Head over to http://nodejs.org/ and click the install button to download the latest package.

nodejs-osx npm

 

 

Install the package from the .dmg by following along the install wizard which will install both node and npm, npm is Node Package Manager which facilitates installs of additional packages for node.js.

osx-yosemite-nodejs-install

 

At the end of the install you are prompted to make sure that /usr/local/bin is in your path, double check you have it by running in the Terminal:

echo $PATH

If not add it in either .bash_profile or .bashrc in your home directory.

After install check it was ok by entering in the command line node which will open a node javascript session:

node

> console.log('hello node');

hello node

undefined

>

To exit the node.js session just hit ‘control’ + ‘c’ twice.

If you have an earlier version of node you can just download the latest version and install to upgrade it and it will over write the previous version.

To check your version of node run …

node -v

Installing Packages for Node

There are many packages for Node such as the popular grunt.js,  you use the command npm to see a complete list run:

npm search

This will return an exhaustive list of available packages, to install a package run npm install

npm install easyimage

To list installed packages from a project directory run

npm ls

To upgrade npm packages

npm update

To upgrade node.js itself on OSX just download and install the latest from node.org

http://coolestguidesontheplanet.com/installing-node-js-on-osx-10-10-yosemite/