Many times, we install software on Mac just to save time. We download. dmg files or.pkg files directly and install them. The configuration and environment variables are all automatically configured, but after installing like node.js, there is no entry point for complete uninstallation. Additionally, sometimes we need multiple environments with different node versions, which makes the above method a bit inconvenient, so it is still recommended to install binary packages and manually configure environment variables.
Directly through a command
brew uninstall nodejs
Through this command
sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}
Write a script, such as uninstallNodejs.sh
1 2 3 4 5 6 7 8 | |
Authorize files
chmod 777 uninstallNodejs.sh
Finally, run the file file
sudo rm /usr/local/bin/npm
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/lib/dtrace/node.d
sudo rm -rf ~/.npm
sudo rm -rf ~/.node-gyp
sudo rm /opt/local/bin/node
sudo rm /opt/local/include/node
sudo rm -rf /opt/local/lib/node_modules
Done!