Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)

My variant of node is consistently v0.6.1-pre even after I install blend node and NVM install v0.6.19.

My node variant is:
node -v
v0.6.1-pre

NVM says this (after I install a version of node for the first time in one bash terminal):
nvm ls
v0.6.19
current: v0.6.19

Yet, when I restart bash, this is the thing that I see:
nvm ls
v0.6.19
current: v0.6.1-pre
default -> 0.6.19 (-> v0.6.19)

So where is this phantom node 0.6.1-pre-version and how might I dispose of it? I'm attempting to install libraries via NPM with the goal that I can work on a project.
by

3 Answers

akshay1995
To remove:

brew uninstall node;

# or `brew uninstall --force node` which removes all versions
brew cleanup;
rm -f /usr/local/bin/npm /usr/local/lib/dtrace/node.d;
rm -rf ~/.npm;

To install:

brew install node;
which node # => /usr/local/bin/node
export NODE_PATH='/usr/local/lib/node_modules' # <--- add this ~/.bashrc

You can run brew info node for more details regarding your node installs.
kshitijrana14
Apparently, there was a /Users/myusername/local folder that contained a include with node and lib with node and node_modules. How and why this was created instead of in my /usr/local folder, I do not know.
Deleting these local references fixed the phantom v0.6.1-pre. If anyone has an explanation, I'll choose that as the correct answer.
EDIT:
You may need to do the additional instructions as well:
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm,node*,man1/node*}

which is the equivalent of (same as above)...
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp 

or (same as above) broken down...
To completely uninstall node + npm is to do the following:
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
You may also need to do:
sudo rm -rf /opt/local/bin/node /opt/local/include/node /opt/local/lib/node_modules
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node.1 /usr/local/lib/dtrace/node.d

Additionally, NVM modifies the PATH variable in $HOME/.bashrc, which must be reverted manually.
Then download nvm and follow the instructions to install node. The latest versions of node come with npm, I believe, but you can also reinstall that as well.
sandhya6gczb
NVM (Node version manager) is a portable solution for managing multiple versions of node

nvm uninstall v4.1.0
> nvm install v8.1.2
> nvm use v8.1.2
> nvm list
v4.2.0
v5.8.0
v6.11.0
-> v8.1.2
system

Login / Signup to Answer the Question.