ref – http://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x
Install Homebrew
Homebrew is a package manager for the Mac — it makes installing most open source sofware (like Node) as simple as writing brew install node. You can learn more about Homebrew at the Homebrew website. To install Homebrew just open Terminal and type:
1 |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
You’ll see messages in the Terminal explaining what you need to do to complete the installation process.
result:
Rickys-MacBook-Pro:~$ ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/…
/usr/local/share/man/man1/brew.1
==> The following directories will be made group writable:
/usr/local/lib/pkgconfig
/usr/local/share/man/man3
/usr/local/share/man/man5
/usr/local/share/man/man7
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/lib/pkgconfig /usr/local/share/man/man3 /usr/local/share/man/man5 /usr/local/share/man/man7
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type “man sudo” for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> Downloading and installing Homebrew…
remote: Counting objects: 3590, done.
remote: Compressing objects: 100% (3433/3433), done.
remote: Total 3590 (delta 28), reused 667 (delta 19), pack-reused 0
Receiving objects: 100% (3590/3590), 2.86 MiB | 322.00 KiB/s, done.
Resolving deltas: 100% (28/28), done.
From https://github.com/Homebrew/homebrew
* [new branch] master -> origin/master
Checking out files: 100% (3594/3594), done.
HEAD is now at 231c429 unac: fix audit warnings
==> Installation successful!
==> Next steps
Run brew help
to get started
Rickys-MacBook-Pro:~ $
Installation
Removing previous installations of NodeJS
If its your first time installing nodeJS, then skip this part go on to the standard installation instructions below
However, if you have previous versions of nodeJS installed, you need to remove previous node folders and files.
- go to /usr/local/lib and delete any node and node_modules
- go to /usr/local/include and delete any node and node_modules directory
- if you installed with brew install node, then run brew uninstall node in your terminal
- check your Home directory for any local or lib or include folders, and delete any node or node_modules from there
- go to /usr/local/bin and delete any node executable
- remove /usr/local/lib/dtrace/node.d
- remove /usr/local/share/man/man1/node.1
Usually every time you do an install, and if there are any issues, it will print out for you…something like this:
brew link
step did not complete successfullyThe formula built, but is not symlinked into /usr/local
Could not symlink share/man/man1/node.1
Target /usr/local/share/man/man1/node.1
already exists. You may want to remove it:
rm ‘/usr/local/share/man/man1/node.1’
Just solve the error, do a “brew uninstall node”, and start the installation all over again.
Actual installation
Installing Node.js and NPM is pretty straightforward using Homebrew. Homebrew handles downloading, unpacking and installing Node and NPM on your system. The whole process (after you have XCode and Homebrew installed) should only take you a few minutes.
Open the Terminal app and type brew install node
Sit back and wait. Homebrew downloads some files and installs them. And that’s it.
After you entered the command you should see the installation go under way:
==> Downloading https://homebrew.bintray.com/bottles/node-0.12.4.yosemite.bottle.tar.
######################################### 75%
==> Downloading https://homebrew.bintray.com/bottles/node-0.12.4.yosemite.bottle.tar.
Already downloaded: /Library/Caches/Homebrew/node-0.12.4.yosemite.bottle.tar.gz
==> Pouring node-0.12.4.yosemite.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/node/0.12.4: 2590 files, 28M
Rickys-MacBook-Pro:~ rickytsao$
After installation, check what version of Node and NPM you’ve just installed:
To see if Node is installed, type node -v in Terminal. This should print the version number so you’ll see something like this v0.10.31.
To see if NPM is installed, type npm -v in Terminal. This should print the version number so you’ll see something like this 1.4.27
How to Update Node and NPM
New versions of Node and NPM come out frequently. You can use Homebrew to update the software it installs.
Make sure Homebrew has the latest version of the Node package. In Terminal type brew update
Upgrade Node: brew upgrade node
How to Uninstall Node and NPM
You can use Homebrew to uninstall packages that it installed: brew uninstall node