Problem
Even after installing brew node and NVM install v0.6.19, my node version is always v0.6.1-pre.
My node version is as follows:
node -v
v0.6.1-pre
After installing a version of node for the first time in one bash terminal, NVM says:
nvm ls
v0.6.19
current: v0.6.19
When I restart bash, though, I get the following:
nvm ls
v0.6.19
current: v0.6.1-pre
default -> 0.6.19 (-> v0.6.19)
So, where did this phantom node 0.6.1-pre version come from, and how do I get rid of it? I’m attempting to use NPM to install libraries so that I can work on a project.
Before NVM, I tried updating using BREW, using brew update and brew install node. I’ve tried removing the “node” directory from my /usr/local/include directory, as well as the “node” and “node modules” directories from my /usr/local/lib directory. Following these steps, I tried uninstalling and reinstalling npm.
All of this happened because I was trying to install the “zipstream” package on an older version of node. Even though NVM indicates it’s running 0.6.19, there are now directories in my users directory, and the node version STILL isn’t up to date.
Ideally, I’d like to remove nodejs, npm, and nvm from my system and reinstall everything from scratch.
Asked by Dominic Tancredi
Solution #1
There was apparently a /Users/myusername/local folder with an include with node, lib with node, and node modules in it. I’m not sure how or why this was created instead of in my /usr/local folder.
The phantom v0.6.1-pre was fixed by deleting these local references. I’ll choose the correct answer if someone offers an explanation.
EDIT:
You may also need to follow the following instructions:
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}
which is the same thing as (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 uninstall node + npm fully, do the following:
You might also have to:
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
NVM also alters the PATH variable in $HOME/.bashrc, which must be manually reversed.
Then, to install node, download nvm and follow the instructions. I believe that the most recent versions of node include npm, however you can reinstall it if necessary.
Answered by Dominic Tancredi
Solution #2
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 lightweight tool for managing various node versions.
> 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
This can be used in conjunction with AVN to automatically swap versions as you go between projects with different node dependencies.
Answered by lfender6445
Solution #3
I realize this is an old topic, but I just wanted to provide the Terminal commands that worked for me while deleting Node.js.
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
This simple tutorial is thanks to jguix.
Create an intermediate file first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom >> ~/filelist.txt
Examine your file by hand (located in your Home folder)
~/filelist.txt
Then delete the files as follows:
cat ~/filelist.txt | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
Thanks Lenar Hoyt
gistcomment-1572198 gistcomment-1572198 gistcomment-1572198 gistcomment-1572198
Original Gist: TonyMtz/d75101d9bdf764c890ef
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
Answered by DaveyJake
Solution #4
I install it from the node package (from the nodejs site) on Mavericks, then uninstall it so I can reinstall it using brew. In the terminal, I only run four commands:
Repeat step 2 if there is still a node installation. After making sure everything is in order, I run brew install node.
Answered by Pedro Polonia
Solution #5
https://stackabuse.com/how-to-uninstall-node-js-from-mac-osx/ To entirely remove a node from a MACOS system, use the commands below.
sudo rm -rf ~/.npm ~/.nvm ~/node_modules ~/.node-gyp ~/.npmrc ~/.node_repl_history
sudo rm -rf /usr/local/bin/npm /usr/local/bin/node-debug /usr/local/bin/node /usr/local/bin/node-gyp
sudo rm -rf /usr/local/share/man/man1/node* /usr/local/share/man/man1/npm*
sudo rm -rf /usr/local/include/node /usr/local/include/node_modules
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /usr/local/lib/dtrace/node.d
sudo rm -rf /opt/local/include/node /opt/local/bin/node /opt/local/lib/node
sudo rm -rf /usr/local/share/doc/node
sudo rm -rf /usr/local/share/systemtap/tapset/node.stp
brew uninstall node
brew doctor
brew cleanup --prune-prefix
After that, I recommend running the following command to install node using nvm (for the most recent version, see https://github.com/nvm-sh/nvm). curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh bash
from https://github.com/nvm-sh/nvm
What’s the deal with nvm? This is an excellent issue; different projects will necessitate different versions of Node, for example, A will necessitate Node version 12 whereas B will necessitate Node version 14. Only nvm is responsible for node version control.
Answered by Akshay Vijay Jain
Post is based on https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x