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:
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
But when I restart bash, this is what 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 can I get rid of it? I'm trying to install libraries via NPM so that I can work on a project.
I tried using BREW to update before NVM, using "brew update" and "brew install node". I've tried deleting the "node" directory in my /usr/local/include and the "node" and "node_modules" in my "/usr/local/lib". I've tried uninstalling npm and reinstalling it following these instructions.
All of this because I was trying to update an older version of node to install the "zipstream" library. Now there's folders in my users directory, and the node version STILL isn't up to date, even though NVM says it's using 0.6.19.
Ideally, I'd like to uninstall nodejs, npm, and nvm, and just reinstall the entire thing from scratch on my system.
downgrade node to 0.10.36
upgrade node to stable v
Additional to the main answer I needed to remove all npm instances found in:
This fixed it for me Fixing npm On Mac OS X for Homebrew Users. And it does not require too many steps.
Just go to the solution part if you don't care about the why.
Here is the relevant part for convenience:
Solution
This solution fixes the error caused by trying to run
npm update npm -g
. Once you're finished, you also won't need to usesudo
to install npm modules globally.Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.
Run the following commands to remove all existing global npm modules, uninstall node & npm, re-install node with the correct defaults, configure the location for global npm modules to be installed, and then install npm as its own pacakge.
Node and npm should be correctly installed at this point. The final step is to add
~/.npm-packages/bin
to yourPATH
so npm and global npm packages are usable. To do this, add the following line to your~/.bash_profile
:Now you can re-install any global npm packages you need without any problems.
On Mavericks I install it from the node pkg (from nodejs site) and I uninstall it so I can re-install using brew. I only run 4 commands in the terminal:
sudo rm -rf /usr/local/lib/node_modules/npm/
brew uninstall node
brew doctor
brew prune
If there is still a node installation, repeat step 2. After all is ok, I install using
brew install node
I know this post is a little dated but just wanted to share the commands that worked for me in Terminal when removing Node.js.
UPDATE:
23 SEP 2016
If you're afraid of running these commands...
Thanks to
jguix
forthis quick tutorial
.First, create an intermediate file:
Manually review your file (located in your
Home
folder)Then delete the files:
For 10.10.5 and above
Thanks
Lenar Hoyt
Gist Comment Source:
gistcomment-1572198
Original Gist:
TonyMtz/d75101d9bdf764c890ef
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:
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.