How To Install / Uninstall Node JS, NPM On Mac

This article will tell you how to install Node JS and NPM(node package manager) on MacOS step by step. There are three ways to install it on mac, run the official installer, install node binary for macOs directly or use mac Homebrew package manager. We will introduce them all.

1. Install Node JS Use Node Installer For Mac.

  1. Download node js mac installer (pkg file) from node js official site.
  2. Click the downloaded file to open installer. Process the installation as normal by click next or continue button. Please note where the node js is installed. It will be installed to /usr/local/bin/node directory. And the npm( node package manager ) will be installed to /usr/local/bin/npm directory.
    install node js for macos wizard
  3. After installation, open a terminal in macos, run node -v and npm -v in the terminal to verify the installation.
    $ node -v
    v8.12.0
    $ npm -v
    6.4.1
  4. Uninstall node js in this way is just to delete node, node_modules folder under below global or your personal folders ( for example/usr/local/lib/node,/usr/local/lib/node_modules).
    /usr/local/lib/, /usr/local/include/, /Users/$user_home_dorectory/lib/, /Users/$user_home_dorectory/local/include

2. Install Node JS Use MacOS Binary.

If you want to use multiple node js version in your mac. You can also download different version of node js zip file, then unzip and save them in different folder. Then you can use different version node js.

  1. Download node js MacOS version binary file.
  2. Unzip the zip file to a local folder, and cd into that folder in terminal. Then you can find the bin folder under it. The node and npm executable file are all saved in the bin folder.
    $ cd /Users/zhaosong/Downloads/node-v8.12.0-darwin-x64

    extracted node js tool files folder

  3. Cd into the bin folder, and execute ./node -v and ./npm -v to verify node and npm version.
  4. If you want to use this node js version conveniently, you can add the bin folder full path ( /Users/zhaosong/Downloads/node-v8.12.0-darwin-x64/bin ) to os system environment variable $PATH. Please refer How To Set JAVA_HOME, MAVEN_HOME Environment Variable In MacOS to learn how to add node bin folder in MacOS $PATH value.
  5. After above step, you can run node command from any directory in terminal, you do not need to go to the node js bin folder to run it.
  6. Uninstall node js in this method is similar with section one in this article. You need to remove the unzip node js folder and related installed node modules.

3. Install Node JS Use MacOS Homebrew.

Homebrew is MacOS package manager tool. You can use it to install MacOS software ( such as node js ) easily.

  1. Run brew -v in terminal to check whether homebrew is installed or not.
    192:bin $ brew -v
    Homebrew 1.7.7
    Homebrew/homebrew-core (git revision 2278; last commit 2018-10-17)
  2. If homebrew do not exist, then run below command in terminal to install it on your MacOS.
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. Then you can install node js use homebrew easily.
    $ brew install node
  4. Upgrade homebrew command.
    $ brew upgrade
  5. To upgrade node with homebrew.
    $ brew upgrade node
  6. It is also very easy to uninstall node js with homebrew.
    $ brew uninstall nod

Reference

  1. How To Use Node Package Manager
(Visited 258 times, 7 visits today)
READ :   Node JS EventEmitter Example

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.