lando2319
lando2319

Reputation: 1810

Unable to uninstall / reinstall Node on Homebrew

In my pursue of solving an unrelated problem I ran the following $ sudo npm i npm -g (DO NOT RUN)

Even though it presented an error, npm was immediately gone. All future attempts to get back to having node and npm have not worked.

I have tried installing node with homebrew, after uninstalling which give me the following:

`$ brew install node
==> Downloading https://homebrew.bintray.com/bottles/node-0.12.7.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-0.12.7.yosemite.bottle.tar.gz
==> Pouring node-0.12.7.yosemite.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
Error: The 'brew link' step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/systemtap/tapset/node.stp
Target /usr/local/share/systemtap/tapset/node.stp
already exists. You may want to remove it:
rm '/usr/local/share/systemtap/tapset/node.stp'`

Since npm comes with Node my though was to reinstall node to get NPM.

Upvotes: 0

Views: 616

Answers (2)

lando2319
lando2319

Reputation: 1810

I ended up having to adjust my permissions to allow homebrew to create the symlinks, the command I used was

$ sudo chown -R username /usr/local/share/systemtap/

Upvotes: 1

Erick Arroyo
Erick Arroyo

Reputation: 142

Try this:

First: 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.*

To recap, the best way (I've found) to completely uninstall node + npm is to do the following:

go to /usr/local/lib and delete any node and node_modules cd /usr/local/lib sudo rm -rf node*

go to /usr/local/include and delete any node and node_modules directory cd /usr/local/include sudo rm -rf node*

if you installed with brew install node, then run brew uninstall node in your terminal brew uninstall node

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 cd /usr/local/bin sudo rm -rf /usr/local/bin/npm ls -las

You may need to do the additional instructions as well: sudo rm -rf /usr/local/share/man/man1/node.1 sudo rm -rf /usr/local/lib/dtrace/node.d sudo rm -rf ~/.npm

Source: https://gist.github.com/TonyMtz/d75101d9bdf764c890ef

Upvotes: 0

Related Questions