Install Node.js on macOS

From Bonus Bits
Jump to: navigation, search


This article gives the steps to install Node.js and NPM on macOS using Homebrew.


Check if Installed

  1. First we should check and see if Node and NPM are installed
  1. node -v
  2. npm -v

Install Node & NPM

  1. Install Node with Homebrew which will install dependencies plus Node Package Manager.
  1. brew install node

Update NPM

  1. The default install Node Package Manager most likely is out-of-date. So, run the follow to update to the latest.
  1. npm update -g

Set icu4c Env Vars (Optional)

One of the dependencies is icu4c-58. We may want to add the pathing caveats:

==> Pouring icu4c-58.2.sierra.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.

macOS provides libicucore.dylib (but nothing else).

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/icu4c/lib
    CPPFLAGS: -I/usr/local/opt/icu4c/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/icu4c/lib/pkgconfig
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile

Set BASH Completion Path Env Var (Optional)

Honestly I do not know if this is needed or helps in any way

Optionally we may want to ensure the BASH Completion is in the path.

==> Pouring node-7.6.0.sierra.bottle.tar.gz
==> Using the sandbox
==> Caveats
Bash completion has been installed to:
echo 'export PATH="/usr/local/etc:$PATH"' >> ~/.bash_profile

Update Node

  1. To update Node and NPM use the following command
  1. brew update node
  2. brew upgrade node
OR to upgrade all brew packages including Node/NPM leave off node from the commands
  1. brew update && brew upgrade

Uninstall Node

  1. To remove Node and NPM use the following command
  1. brew uninstall node

Related Articles