javascript tutorial - [Solved-5 Solutions] How do we completely uninstall Node.js, and reinstall from beginning(Mac OS X) - javascript - java script - javascript array



Problem:

My version of node is always v0.6.1-pre even after WE install brew node and NVM install v0.6.19. My node version is:

node -v
v0.6.1-pre
click below button to copy the code. By JavaScript tutorial team

NVM says this (after WE install a version of node for the first time in one bash terminal):

nvm ls
v0.6.19
current:    v0.6.19
click below button to copy the code. By JavaScript tutorial team

But when WE restart bash, this is what WE see:

nvm ls
v0.6.19
current:    v0.6.1-pre
default -> 0.6.19 (-> v0.6.19)
click below button to copy the code. By JavaScript tutorial team

So where is this phantom node 0.6.1-pre version and how can WE get rid of it? I'm trying to install libraries via NPM so that WE can work on a project. WE 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 we were 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.

Solution 1:

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/localfolder, WE 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:

We 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*}
click below button to copy the code. By JavaScript tutorial team

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 /opt/local/bin/node opt/local/include/node /opt/local/lib/node_modules
click below button to copy the code. By JavaScript tutorial team

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 we installed with brew install node, then run brew uninstall node in our terminal
  • check our 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

Then download nvm and follow the instructions to install node. The latest versions of node come with npm, WE believe, but we can also reinstall that as well.

Solution 2:

For brew users, OSX:

To remove:

brew uninstall node; 
# or `brew uninstall --force node` which removes all versions
brew prune;
rm -f /usr/local/bin/npm /usr/local/lib/dtrace/node.d;
rm -rf ~/.npm;
click below button to copy the code. By JavaScript tutorial team

To install:

brew install node;
which node # => /usr/local/bin/node
export NODE_PATH='/usr/local/lib/node_modules' # <--- add this ~/.bashrc
click below button to copy the code. By JavaScript tutorial team

We can run brew info node for more details regarding our node installs.

consider using NVM instead of brew

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
click below button to copy the code. By JavaScript tutorial team
  • we can use this with AVN to automatically switch versions as we hop between different projects with different node dependencies.

Solution 3:

WE know this post is a little dated but just wanted to share the commands that worked for me in Terminal when removing 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.*
click below button to copy the code. By JavaScript tutorial team

UPDATE:

If you're afraid of running these commands... Thanks to jguix . First, create an intermediate file:

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom >> ~/filelist.txt
click below button to copy the code. By JavaScript tutorial team

Manually review our file (located in our Home folder)

 ~/filelist.txt
click below button to copy the code. By JavaScript tutorial team

Then delete the files:

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.*
click below button to copy the code. By JavaScript tutorial team
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.*

click below button to copy the code. By JavaScript tutorial team

Solution 4:

On Mavericks WE install it from the node pkg (from nodejs site) and WE uninstall it so WE can re-install using brew. WE 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, WE install using brew install node

Solution 5:

downgrade node to 0.10.36

  sudo npm cache clean -f
  sudo npm install -g n
  sudo n 0.10.36
click below button to copy the code. By JavaScript tutorial team

upgrade node to stable v

  sudo npm cache clean -f
  sudo npm install -g n
  sudo n stable

click below button to copy the code. By JavaScript tutorial team

Related Searches to javascript tutorial - How do we completely uninstall Node.js, and reinstall from beginning(Mac OS X)