My version of node is always v0.6.1-pre even after I install brew node and NVM install v0.6.19.
My node version is:
After
brew uninstall node
I had to know which node
which node
then remove that
rm -rf /usr/local/bin/node
I have summarized the existing answers and made sure Node.js is COMPLETELY ERASED along with NPM.
Lines to copy to terminal:
brew uninstall node;
which node;
sudo rm -rf /usr/local/bin/node;
sudo rm -rf /usr/local/lib/node_modules/npm/;
brew doctor;
brew cleanup --prune-prefix;
If you're unable to locate node just run whereis node
and whereis npm
and whereis nvm
and you can remove the listed directories as needed.
You'll also need to entirely close your terminal and reopen it for changes to take effect.
I have been hit by an issue during uninstall of Node.js on my mac. I had some strange behavior like npm
is still their even after having removing it with all this.
It was because I had an old install done with macport. So you also have to uninstall it using port:
sudo port uninstall nodejs
It may have install many different versions of Node.js so uninstall them all (one by one).
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.
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
you can use this with AVN to automatically switch versions as you hop between different projects with different node dependencies.
Expanding on Dominic Tancredi's awesome answer, I've rolled this into a bash package and stand-alone script. If you are already using the "Back Package Manager" called bpkg you can install the script by running:
bpkg install -g brock/node-reinstall
Or you can have a look at the script on Github at brock/node-reinstall. The script allows you to re-install node using nvm or nave, and to specify a node version as your default.