Node.js

Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine.

Installation

Using Homebrew

  1. $ brew install node

Using Node Version Manager (nvm)

Download and install nvm by running:

  1. $ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash

Then download Node and select your version by running:

  1. $ source ~/.bashrc # source your bashrc/zshrc to add nvm to PATH
  2. $ command -v nvm # check the nvm use message
  3. $ nvm install node # install most recent Node stable version
  4. $ nvm ls # list installed Node version
  5. $ nvm use node # use stable as current version
  6. $ nvm ls-remote # list all the Node versions you can install
  7. $ nvm alias default node # set the installed stable version as the default Node

See the documentation for information.

npm usage

To install a package:

  1. $ npm install <package> # Install locally
  2. $ npm install -g <package> # Install globally

To install a package and save it in your project’s package.json file:

  1. $ npm install <package> --save

To see what’s installed:

  1. $ npm list [-g]

To find outdated packages:

  1. $ npm outdated [-g]

To upgrade all or a particular package:

  1. $ npm update [-g] [<package>]

To uninstall a package:

  1. $ npm uninstall [-g] <package>