Complete uninstall Nodejs on macOS Big Sur version 11.2.3 (20D91)
Introduction
First thing first,
I want to say thank you for sharing this trick @tonymtz.
My system is running macOS Big Sur version 11.2.3 (20D91)
with nodejs Latest Current Version: 15.14.0 (includes npm 7.7.6)
installed from the official website.
I tried to fully uninstall nodejs
on my MacBook Pro in order to re-install it with homebrew
package manager using:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
but I was facing an issue like @AhteshamShah mentioned in @JohelAlvarez's answer:
When fired first command getting: can't open /var/db/receipts/org.nodejs.pkg.bom: No such file or directory **** Can't open /var/db/receipts/org.nodejs.pkg.bom.
Please help – Ahtesham Shah Jun 20 '19 at 5:09
I dived into the original post linked by @JohelAlvarez, reading all the comments and I've found this comment from @e2tha-e:
@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!
@e2tha-e was right, 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
.
Solution for installation from Nodejs's official website
With your preferred Terminal, fully uninstall Nodejs from your system like this :
Option 1lsbom -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.*
Option 2Go to /var/db/receipts/
and delete any org.nodejs.*
cd /var/db/receipts/ && ls -la
sudo rm -rf org.nodejs.*
Go to /usr/local/lib
and delete any node
and node_modules
cd /usr/local/lib && ls -la
sudo rm -rf node*
Go to /usr/local/include
and delete any node
and node_modules
directory
cd /usr/local/include && ls -la
sudo rm -rf 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 && ls -la
sudo rm -rf /usr/local/bin/npm
sudo rm -rf /usr/local/bin/node
You may need to do this too:
sudo rm -rf /usr/local/share/man/man1/node.1
sudo rm -rf /usr/local/lib/dtrace/node.d
sudo rm -rf ~/.npm
After that, you can check if there is still node
in your system with which node
or find all occurrences for node in your system.
Tips
- Search where node files are with
find / -name 'node' | sed -E 's|/[^/]+$||' |sort -u
- Before running shared code by others, check your directories before to make sure you write the right file name.
🖖