Skip to content

Instantly share code, notes, and snippets.

@tonymtz
Last active July 26, 2024 20:17
Show Gist options
  • Save tonymtz/d75101d9bdf764c890ef to your computer and use it in GitHub Desktop.
Save tonymtz/d75101d9bdf764c890ef to your computer and use it in GitHub Desktop.
Uninstall nodejs from OSX Yosemite
# 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
sudo rm -rf /usr/local/bin/node
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
@pytugu
Copy link

pytugu commented Feb 15, 2018

Cool! Thanks

@zatmar
Copy link

zatmar commented Feb 15, 2018

Thanks dude!

@woelfle
Copy link

woelfle commented Apr 22, 2018

Great. Many thranks

@HongJheLi
Copy link

Wonderful tips. Thank you so much.

Copy link

ghost commented Jun 12, 2018

THNX

@erperejildo
Copy link

after all of this when I type node -v still showing me v6.14.3

@abdelhakim-85
Copy link

Thank you so much it helped me

@krystonen
Copy link

Quick and easy. thanks!

@GabiAcea
Copy link

Check the $Path variable 'echo $PATH' to check where is 'node -v' command looking. And remove it from there.

@jmosky
Copy link

jmosky commented Apr 6, 2019

Thank you so much for this!

@ehaynie63
Copy link

yay I think this worked. Mojave

@petrchutny
Copy link

Thanks a lot :) It helped me too!

@izzyjr
Copy link

izzyjr commented May 3, 2019

Mojave here.
After typing node -v in my terminal I should expect: "-bash: node: command not found"?

@blendaguedes-zz
Copy link

Thank you so much! Struggling with it a lot. Savior!

@muet
Copy link

muet commented Dec 20, 2019

not working at all. still get module not found... somehow, node modules get installed in wrong path in project when using mvn jgitflow finish release w/ --- frontend-maven-plugin:1.4:npm (run-npm-install) @

@tonymtz
Copy link
Author

tonymtz commented Dec 20, 2019

not working at all. still get module not found... somehow, node modules get installed in wrong path in project when using mvn jgitflow finish release w/ --- frontend-maven-plugin:1.4:npm (run-npm-install) @

It sounds like your installation is not correct. It is not related to this gist at all.

@divyamb
Copy link

divyamb commented Feb 26, 2020

thank you for this!

@rselva
Copy link

rselva commented May 28, 2020

Worked like charm!!!

@elulcao
Copy link

elulcao commented Nov 22, 2020

Thanks for sharing 👍

@torojin
Copy link

torojin commented Jan 16, 2021

Thanks for this!

@devnoyo0123
Copy link

Thanks. It saves the time of absolutely removing the node.js

@DYW972
Copy link

DYW972 commented Apr 8, 2021

Thank you for sharing @tonymtz 👍

Very helpful trick!

But as @e2tha-e wrote (thank you too 👍)

@tonymtz On my installation of Node v4.0.0 on Yosemite 10.10.5, the first line needed to be
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
A different filename from org.nodejs.pkg.bom
Otherwise, this worked like a charm!

On macOS Big Sur version 11.2.3 (20D91) with nodejs Latest Current Version: 15.14.0 (includes npm 7.7.6) installed from official website, the file name is not org.nodejs.pkg.bom but org.nodejs.**node**.pkg.bom .

You can check this when you cd /var/db/receipts/ && ls -la.

So everyone, who wants to use this trick, please check the /var/db/receipts/ directory before to make sure you write the right file name.

Normally after that everything is ok.

thank you again @tonymtz & @e2tha-e

🖖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment