This time I will show you how to completely uninstall node and npm in Mac. What are the precautions? Here are actual cases, let’s take a look.
Using nvm to manage node versions is very convenient. You can switch between different versions freely, but nvminstalls The node is under ~/.nvm, which is the same as the one installed before We are not together, and I have a bit of obsessive-compulsive disorder, so I want to uninstall the previous one
homebrew installed
directly command
brew uninstall node
Official website to download the pkg installation package
One command
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
Installation by other ways
Make a script to put the needsDelete files, kill them all in one stroke
The content is as follows, named: uninstallnode.sh
#!/bin/bash lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom \ | while read i; do sudo rm /usr/local/${i} done sudo rm -rf /usr/local/lib/node \ /usr/local/lib/node_modules \ /var/db/receipts/org.nodejs.*
Modify file permissions chmod 777 uninstallNodejs.sh
Execute on the command line
Tips:
After deleting these things, the node will be deleted.
But there are a lot of software and command line tools installed based on node, which also need to be reinstalled, such as react-native, supervisor, pm2 etc
Need to delete /usr/local/bin The following related files are actually just soft links, and they are all located in the /usr/local/lib/node_modules/ directory.
In the previous steps, it has been deleted, but you can still find it by pressing the tab key because these soft connections still exist.
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
How to use AngularJS to implement tab switching
How to use Koa2 to develop WeChat 2D Scan the QR code to pay
The above is the detailed content of How to completely uninstall node and npm on Mac. For more information, please follow other related articles on the PHP Chinese website!